os_calls: Add g_setpgid()

This commit is contained in:
matt335672 2023-04-17 15:19:38 +01:00
parent 65ff618479
commit cf5e1961d3
2 changed files with 28 additions and 1 deletions

View File

@ -3158,7 +3158,7 @@ g_waitchild(struct exit_status *e)
e->reason = E_XR_UNEXPECTED;
e->val = 0;
rv = waitpid(0, &wstat, WNOHANG);
rv = waitpid(-1, &wstat, WNOHANG);
if (rv == -1)
{
@ -3253,6 +3253,24 @@ g_waitpid_status(int pid)
return exit_status;
}
/*****************************************************************************/
int
g_setpgid(int pid, int pgid)
{
int rv = setpgid(pid, pgid);
if (rv < 0)
{
if (pid == 0)
{
pid = getpid();
}
LOG(LOG_LEVEL_ERROR, "Can't set process group ID of %d to %d [%s]",
pid, pgid, g_get_strerror());
}
return rv;
}
/*****************************************************************************/
/* does not work in win32 */
void

View File

@ -297,6 +297,15 @@ int g_set_allusercontext(int uid);
int g_waitchild(struct exit_status *e);
int g_waitpid(int pid);
struct exit_status g_waitpid_status(int pid);
/*
* Sets the process group ID of the indicated process to the specified value.
* (POSIX.1)
*
* Errors are logged.
*
* May do nothing if process groups are not supported
*/
int g_setpgid(int pid, int pgid);
void g_clearenv(void);
int g_setenv(const char *name, const char *value, int rewrite);
char *g_getenv(const char *name);