mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-27 04:50:28 +00:00
Add posix_spawn (#114)
This commit is contained in:
parent
5f088cec23
commit
5ce83b08c8
10 changed files with 521 additions and 22 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
*
|
||||
* @return 0 on success, or -1 w/ errno
|
||||
* @asyncsignalsafe
|
||||
* @vforksafe
|
||||
*/
|
||||
int sigfillset(sigset_t *set) {
|
||||
memset(set->__bits, -1, sizeof(set->__bits));
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
*
|
||||
* @return true, false, or -1 w/ errno
|
||||
* @asyncsignalsafe
|
||||
* @vforksafe
|
||||
*/
|
||||
int sigismember(const sigset_t *set, int sig) {
|
||||
unsigned i = sig - 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue