swc

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/swc
Log | Files | Refs | README | LICENSE

commit f380adac3b0ae5253016e7fbeee8dd3b81dff304
parent 5f348ea439c24ae531dd202cbc82f0c88940788a
Author: Michael Forney <mforney@mforney.org>
Date:   Thu, 15 Nov 2018 23:20:45 -0800

launch: Use posix_spawn correctly

These functions don't set errno, and we need to make sure to initialize
the posix_spawnattr_t.

Diffstat:
Mlaunch/launch.c | 15+++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/launch/launch.c b/launch/launch.c @@ -462,13 +462,16 @@ main(int argc, char *argv[]) sprintf(buf, "%d", sock[1]); setenv(SWC_LAUNCH_SOCKET_ENV, buf, 1); - if (posix_spawnattr_setflags(&attr, POSIX_SPAWN_RESETIDS|POSIX_SPAWN_SETSIGMASK) != 0) - die("failed to set spawnattr flags:"); + if ((errno = posix_spawnattr_init(&attr))) + die("posix_spawnattr_init:"); + if ((errno = posix_spawnattr_setflags(&attr, POSIX_SPAWN_RESETIDS|POSIX_SPAWN_SETSIGMASK))) + die("posix_spawnattr_setflags:"); sigemptyset(&set); - if (posix_spawnattr_setsigmask(&attr, &set) != 0) - die("failed to set spawnattr sigmask:"); - if (posix_spawnp(&pid, argv[optind], NULL, &attr, argv + optind, environ) != 0) - die("failed to spawn server:"); + if ((errno = posix_spawnattr_setsigmask(&attr, &set))) + die("posix_spawnattr_setsigmask:"); + if ((errno = posix_spawnp(&pid, argv[optind], NULL, &attr, argv + optind, environ))) + die("posix_spawnp %s:", argv[optind]); + posix_spawnattr_destroy(&attr); run(sock[0]);