mirror of
https://github.com/fluencelabs/musl
synced 2025-07-04 09:02:02 +00:00
have posix_spawnattr_setflags check for supported flags
per POSIX, EINVAL is not a mandatory error, only an optional one. but
reporting unsupported flags allows an application to fallback
gracefully when a requested feature is not supported. this is not
helpful now, but it may be in the future if additional flags are
added.
had this checking been present before, applications would have been
able to check for the newly-added POSIX_SPAWN_SETSID feature (added in
commit bb439bb171
) at runtime.
This commit is contained in:
@ -1,7 +1,18 @@
|
|||||||
#include <spawn.h>
|
#include <spawn.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
int posix_spawnattr_setflags(posix_spawnattr_t *attr, short flags)
|
int posix_spawnattr_setflags(posix_spawnattr_t *attr, short flags)
|
||||||
{
|
{
|
||||||
|
const unsigned all_flags =
|
||||||
|
POSIX_SPAWN_RESETIDS |
|
||||||
|
POSIX_SPAWN_SETPGROUP |
|
||||||
|
POSIX_SPAWN_SETSIGDEF |
|
||||||
|
POSIX_SPAWN_SETSIGMASK |
|
||||||
|
POSIX_SPAWN_SETSCHEDPARAM |
|
||||||
|
POSIX_SPAWN_SETSCHEDULER |
|
||||||
|
POSIX_SPAWN_USEVFORK |
|
||||||
|
POSIX_SPAWN_SETSID;
|
||||||
|
if (flags & ~all_flags) return EINVAL;
|
||||||
attr->__flags = flags;
|
attr->__flags = flags;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user