Annotation of researchv10no/ipc/internet/whatsup.c, revision 1.1.1.1

1.1       root        1: #include <stdio.h>
                      2: #include <signal.h>
                      3: int fd;
                      4: 
                      5: catch(i)
                      6:        int i;
                      7: {
                      8:        char buf[32];
                      9: 
                     10:        sprintf(buf, "signal %d\n", i);
                     11:        write(fd, buf, strlen(buf));
                     12:        close(fd);
                     13:        exit(1);
                     14: }
                     15: 
                     16: main()
                     17: {
                     18:        int i;
                     19:        char c;
                     20: 
                     21:        unlink("/tmp/whatsup");
                     22:        fd = creat("/tmp/whatsup", 0666);
                     23:        for (i = 0; i < 32; i++)
                     24:                signal(i, catch);
                     25:        signal(SIGHUP, SIG_IGN);
                     26:        signal(SIGPIPE, SIG_IGN);
                     27:        while(read(0, &c, 1)==1) {
                     28:                if (write(1, &c, 1)!=1) {
                     29:                        write(fd, "ERROR 1\n", 8);
                     30:                        exit(1);
                     31:                }
                     32:                write(fd, &c, 1);
                     33:        }
                     34:        if(write(1, "EOF\n", 4)!=4) {
                     35:                write(fd, "ERROR 2\n", 8);
                     36:                exit(1);
                     37:        }
                     38:        write(fd, "EOF\n", 4);
                     39:        exit(0);
                     40: }

unix.superglobalmegacorp.com

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