From owner-freebsd-hackers Tue Apr 23 16:50:31 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id QAA19310 for hackers-outgoing; Tue, 23 Apr 1996 16:50:31 -0700 (PDT) Received: from vent.pipex.net (root@vent.pipex.net [158.43.128.5]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id QAA19277 for ; Tue, 23 Apr 1996 16:50:20 -0700 (PDT) Received: from dial.pipex.com by vent.pipex.net (8.6.12/PIPEX simple 1.20) id AAA16731; Wed, 24 Apr 1996 00:49:38 +0100 Received: (from jraynard@localhost) by dial.pipex.com (8.6.12/8.6.12) id XAA01870; Tue, 23 Apr 1996 23:47:57 GMT Date: Tue, 23 Apr 1996 23:47:57 GMT From: James Raynard Message-Id: <199604232347.XAA01870@dial.pipex.com> To: julian@ref.tfs.com CC: hackers@freebsd.org In-reply-to: <199604222244.PAA20222@ref.tfs.com> (julian@ref.tfs.com) Subject: Re: Flaws in system() implementation? Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk >>>>> "JULIAN Elischer" writes: > > > Inspired by Rich Stevens' implementation of system() in his book > > "Advanced Programming in the Unix Environment", I've been looking at > > the FreeBSD implementation and was struck by the following points:- > > > > 1. Use of a wait union when an int would do. > This is the correct POSIX thing to do.. > check the man page for wait. According to the 2.1.0-RELEASE man page, wait and friends use an int* for the status variable. > > 3. Returns 0 if fork() fails, when -1 seems more appropriate. > POSIX says: Thanks for posting this, I don't have access to any POSIX specs (except the odd snippet in books). What's the best way of getting hold of them? > If "command" is a null pointer, the system() function returns non-zero > only if a command processor is available. OK (Out of interest, what kind of circumstances would result in a command processor not being available?) > If "command" is a nin null pointer the system() function returnsa > the termination status of the command language interpretter in the > format specified by the waitpid() function. OK > [...] > If a child process cannot be created, > or if the termination status of hte command interpretter cannot be obtained > system() returns -1 > and sets errno to indicate the error. Doesn't that imply that system() should return -1 if fork() fails? (Forgive me if I'm being obtuse, I'm not very experienced at reading standardese). > > 4. The SIGINT and SIGQUIT are not ignored until after the fork(). > > If the child runs first, one of these signals could in theory be > the child MUST run first in vfork() I know, but I'm trying not to use vfork(), in view of the recent discussion (in -current, I think) about replacing it with a call to fork(). Cheers James