Annotation of researchv10no/cmd/sign/ix.c, revision 1.1

1.1     ! root        1: #include <signal.h>
        !             2: #include <errno.h>
        !             3: #include <sgtty.h>
        !             4: 
        !             5: char *pexpw();
        !             6: 
        !             7: char *
        !             8: pexpw(fd, prompt)
        !             9: char *prompt;
        !            10: {
        !            11:        int (*sf)();
        !            12:        /* struct pexclude x; */
        !            13:        struct sgttyb usual, special;
        !            14:        register char *p;
        !            15:        register i;
        !            16:        static char pbuf[9];
        !            17: 
        !            18:        sf = signal(SIGINT, SIG_IGN);
        !            19:        p = pbuf;
        !            20: 
        !            21:        /* if(pex(fd, -1, &x)==0) */
        !            22:        {
        !            23:                /*
        !            24:                if(x.farpid>0 && x.farcap == 0) {
        !            25:                        p = 0;
        !            26:                        goto out;
        !            27:                }
        !            28:                */
        !            29:                ioctl(fd, TIOCGETP, &usual);
        !            30:                special.sg_flags = usual.sg_flags & ~ECHO;
        !            31:                ioctl(fd, TIOCSETP, &special);
        !            32: 
        !            33:                write(fd, prompt, strlen(prompt));
        !            34:                for(i=0;;) {
        !            35:                        char c;
        !            36:                        if(read(fd, &c, 1) != 1 || c == '\n')
        !            37:                                break;
        !            38:                        if(i<8)
        !            39:                                pbuf[i++] = c;
        !            40:                }
        !            41:                while(i<9)
        !            42:                        pbuf[i++] = 0;
        !            43:                ioctl(fd, TIOCSETP, &usual);
        !            44:        }
        !            45:        /*
        !            46:        else
        !            47:                p = 0;
        !            48:        */
        !            49: out:
        !            50:        /* unpex(fd, -1); */
        !            51:        (void) signal(SIGINT, sf);
        !            52:        if(p)write(fd,"\n",1);
        !            53:        return(p);
        !            54: }

unix.superglobalmegacorp.com

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