etc/services - sync with NetBSD-8
[minix.git] / minix / lib / libc / sys / setpgid.c
blobb724fa44c20537533c607ddd41906b47dbb30fef
1 #include <sys/cdefs.h>
2 #include <lib.h>
3 #include "namespace.h"
5 #include <string.h>
7 #include <unistd.h>
9 /*
10 * "Smart" stub for now. This requires job control to be properly implemented.
12 int setpgid(pid_t pid, pid_t pgid)
14 pid_t _pid, _pgid, cpid;
16 _pid = pid;
17 _pgid = pgid;
19 /* Who are we? */
20 cpid = getpid();
22 /* if zero, means current process. */
23 if (_pid == 0) {
24 _pid = cpid;
27 /* if zero, means given pid. */
28 if (_pgid == 0) {
29 _pgid = _pid;
32 /* right now we only support the equivalent of setsid(), which is
33 * setpgid(0,0) */
34 if ((_pid != cpid) || (_pgid != cpid)) {
35 errno = EINVAL;
36 return -1;
39 if (setsid() == cpid) {
40 return 0;
41 } else {
42 return -1;