Subject: Re: /bin/sh "Cannot vfork" behaviour
To: Alan Barrett <apb@cequrux.com>
From: David Laight <david@l8s.co.uk>
List: tech-userlevel
Date: 10/28/2003 18:20:28
On Mon, Oct 27, 2003 at 11:14:25AM +0200, Alan Barrett wrote:
> What is the following command supposed to do if the maxproc limit is
> exceeded?
> 
> 	$ /bin/sh -c "set -x ; ulimit -p 1 ; date || exit 75" ; \
> 			echo status=$?
> 	+ ulimit -p 1
> 	+ date
> 	Cannot vfork
> 	status=2
> 
> Is it a bug that the exit status is 2 rather than 75?

Posix doesn't explicitely mention fork failing :-(
There is the table:
http://www.opengroup.org/onlinepubs/007904975/utilities/xcu_chap02.html#tag_02_08_01

Which has 'May Exit' for 'Command not found'.
I suspect that 'Exit' for 'fork failed' is ok.

I suspect the 'exit' is the traditional behaviour for fork failing in a
non-interactive shell.
A traditional bourne shell (and pdksh) will sleep and retry the fork,
NetBSD's /bin/sh doesn't.

-- 
David Laight: david@l8s.co.uk