File:  [Research Unix] / researchv10no / ipc / internet / whatsup.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:21:34 2018 UTC (8 years, 1 month ago) by root
Branches: belllabs, MAIN
CVS tags: researchv10, HEAD
researchv10 Norman

#include <stdio.h>
#include <signal.h>
int fd;

catch(i)
	int i;
{
	char buf[32];

	sprintf(buf, "signal %d\n", i);
	write(fd, buf, strlen(buf));
	close(fd);
	exit(1);
}

main()
{
	int i;
	char c;

	unlink("/tmp/whatsup");
	fd = creat("/tmp/whatsup", 0666);
	for (i = 0; i < 32; i++)
		signal(i, catch);
	signal(SIGHUP, SIG_IGN);
	signal(SIGPIPE, SIG_IGN);
	while(read(0, &c, 1)==1) {
		if (write(1, &c, 1)!=1)	{
			write(fd, "ERROR 1\n", 8);
			exit(1);
		}
		write(fd, &c, 1);
	}
	if(write(1, "EOF\n", 4)!=4) {
		write(fd, "ERROR 2\n", 8);
		exit(1);
	}
	write(fd, "EOF\n", 4);
	exit(0);
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.