Annotation of researchv9/cmd/hang.c, revision 1.1.1.1

1.1       root        1: #include <stdio.h>
                      2: #include <signal.h>
                      3: #include <sys/pioctl.h>
                      4: 
                      5: main(argc,argv)
                      6: int argc; char **argv;
                      7: {
                      8:        int pfd;
                      9:        char procnam[16];
                     10:        long mask = (1<<(SIGSTOP-1));
                     11:        FILE *ttyerr;
                     12: 
                     13:        ttyerr = fopen("/dev/tty", "w");
                     14:        if (argc <= 1) {
                     15:                if( ttyerr )
                     16:                        fprintf(ttyerr,"Usage: %s cmd [args...]\n",*argv);
                     17:                exit(1);
                     18:        }
                     19:        sprintf(procnam,"/proc/%05d",getpid());
                     20:        if ((pfd=open(procnam,0)) < 0) {
                     21:                if( ttyerr )
                     22:                        fprintf(ttyerr,"cannot open %s\n",procnam);
                     23:                exit(1);
                     24:        }
                     25:        ioctl(pfd,PIOCSMASK,&mask);
                     26:        ioctl(pfd,PIOCSEXEC,0);
                     27:        close(pfd);
                     28:        if( ttyerr ){
                     29:                fprintf(ttyerr,"%s\n",procnam);
                     30:                fclose(ttyerr);
                     31:        }
                     32:        execvp(argv[1], argv+1);
                     33:        perror(argv[1]);
                     34:        exit(1);
                     35: }

unix.superglobalmegacorp.com

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