snoyberg · GitHub

This should fix FreeBSD as well based on the manpage (I don't have a FreeBSD machine to test it on)

RETURN VALUES
     Upon successful completion, posix_spawn() and posix_spawnp() return the
     process ID	of the child process to	the parent process, in the variable
     pointed to	by a non-NULL pid argument, and	return zero as the function
     return value.  Otherwise, no child	process	is created, no value is	stored
     into the variable pointed to by pid, and an error number is returned as
     the function return value to indicate the error.  If the pid argument is
     a null pointer, the process ID of the child is not	returned to the
     caller.

from https://www.freebsd.org/cgi/man.cgi?query=posix_spawn&sektion=3

OpenBSD sets an errno so the old behaviour was fine.

In case of an error, both functions may return fork() or exec() return values and set errno accordingly.

from https://man.openbsd.org/posix_spawn.3

Read the original on github.com ↗