Date: Tue, 24 Dec 2002 12:40:25 +0100 From: Poul-Henning Kamp <phk@freebsd.org> To: current@freebsd.org Subject: revoke(2) redux... Message-ID: <30917.1040730025@critter.freebsd.dk>
next in thread | raw e-mail | index | archive | help
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
phk@FreeBSD.ORG | 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 majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?30917.1040730025>
