I've been studying revoke(2), and somehow fail to see it fulfill
its promise from the man-page.

Consider this piece of code from init(8):

        >/*
        > * Start a session and allocate a controlling terminal.
        > * Only called by children of init after forking.
        > */
        >void
        >setctty(char *name)
        >{
        >        int fd;
        > 
        >        (void) revoke(name);
        >        if ((fd = open(name, O_RDWR)) == -1) {
        >                stall("can't open %s: %m", name);
        >                _exit(1);
        >        }

Isn't there a pretty obvious race between the revoke() and the open() ?

Wouldn't it in fact make much more sense if revoke(2) was defined as

        int revoke(int fd);     /* kick everybody else off */

and the code above would look like:

        >        if ((fd = open(name, O_RDWR)) == -1) {
        >                stall("can't open %s: %m", name);
        >                _exit(1);
        >        }
        >        (void) revoke(fd);


-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
[EMAIL PROTECTED]         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to