Date: Tue, 23 Apr 1996 23:47:57 GMT From: James Raynard <jraynard@dial.pipex.com> To: julian@ref.tfs.com Cc: hackers@freebsd.org Subject: Re: Flaws in system() implementation? Message-ID: <199604232347.XAA01870@dial.pipex.com> In-Reply-To: <199604222244.PAA20222@ref.tfs.com> (julian@ref.tfs.com)
next in thread | previous in thread | raw e-mail | index | archive | help
>>>>> "JULIAN Elischer" <julian@ref.tfs.com> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199604232347.XAA01870>