Add posix_spawn (#114)

This commit is contained in:
Justine Tunney 2021-03-07 20:14:07 -08:00
parent 5f088cec23
commit 5ce83b08c8
10 changed files with 521 additions and 22 deletions

View file

@ -41,40 +41,36 @@ static textwindows noinline uint32_t GetUserNameHash(void) {
return KnuthMultiplicativeHash32(buf, size >> 1);
}
static uint32_t getuidgid(int at, uint32_t impl(void)) {
/**
* Returns real user id of process.
*
* This never fails. On Windows, which doesn't really have this concept,
* we return a deterministic value that's likely to work.
*
* @asyncsignalsafe
* @vforksafe
*/
uint32_t getuid(void) {
if (!IsWindows()) {
if (at != -1) {
return getauxval(at);
} else {
return impl();
}
return sys_getuid();
} else {
return GetUserNameHash();
}
}
/**
* Returns real user id of process.
*
* This never fails. On Windows, which doesn't really have this concept,
* we return a deterministic value that's likely to work. On Linux, this
* is fast.
*
* @asyncsignalsafe
*/
uint32_t getuid(void) {
return getuidgid(AT_UID, sys_getuid);
}
/**
* Returns real group id of process.
*
* This never fails. On Windows, which doesn't really have this concept,
* we return a deterministic value that's likely to work. On Linux, this
* is fast.
* we return a deterministic value that's likely to work.
*
* @asyncsignalsafe
* @vforksafe
*/
uint32_t getgid(void) {
return getuidgid(AT_GID, sys_getgid);
if (!IsWindows()) {
return sys_getgid();
} else {
return GetUserNameHash();
}
}