Overhaul process spawning

This commit is contained in:
Justine Tunney 2023-09-10 08:12:43 -07:00
parent 99dc1281f5
commit 26e254fb4d
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
96 changed files with 1848 additions and 1541 deletions

View file

@ -26,6 +26,10 @@
/**
* Changes process group for process.
*
* @param pid is process id (may be zero for current process)
* @param pgid is process group id (may be zero for current process)
* @return 0 on success, or -1 w/ errno
* @vforksafe
*/
int setpgid(int pid, int pgid) {
@ -35,16 +39,14 @@ int setpgid(int pid, int pgid) {
} else {
me = getpid();
if ((!pid || pid == me) && (!pgid || pgid == me)) {
/*
* "When a process is created with CREATE_NEW_PROCESS_GROUP
* specified, an implicit call to SetConsoleCtrlHandler(NULL,TRUE)
* is made on behalf of the new process; this means that the new
* process has CTRL+C disabled. This lets shells handle CTRL+C
* themselves, and selectively pass that signal on to
* sub-processes. CTRL+BREAK is not disabled, and may be used to
* interrupt the process/process group."
* Quoth MSDN § CreateProcessW()
*/
// "When a process is created with kNtCreateNewProcessGroup
// specified, an implicit call to SetConsoleCtrlHandler(NULL,TRUE)
// is made on behalf of the new process; this means that the new
// process has CTRL+C disabled. This lets shells handle CTRL+C
// themselves, and selectively pass that signal on to
// sub-processes. CTRL+BREAK is not disabled, and may be used to
// interrupt the process/process group."
// ──Quoth MSDN § CreateProcessW()
if (SetConsoleCtrlHandler(0, 1)) {
rc = 0;
} else {