Skip to content

Commit

Permalink
Remove some duplicate code
Browse files Browse the repository at this point in the history
setpgrp() is the same as setpgid(0, 0)
  • Loading branch information
th-otto committed Apr 19, 2024
1 parent e22d60d commit dca3288
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 25 deletions.
2 changes: 0 additions & 2 deletions include/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,6 @@ extern __pid_t __getpgrp (void) __THROW;
#endif

/* Get the process group ID of process PID. */
extern __pid_t __getpgid (__pid_t __pid) __THROW;
#ifdef __USE_XOPEN_EXTENDED
extern __pid_t getpgid (__pid_t __pid) __THROW;
#endif
Expand All @@ -576,7 +575,6 @@ extern __pid_t getpgid (__pid_t __pid) __THROW;
If PID is zero, the current process's process group ID is set.
If PGID is zero, the process ID of the process is used. */
extern int setpgid (__pid_t __pid, __pid_t __pgid) __THROW;
extern int __setpgid (__pid_t __pid, __pid_t __pgid) __THROW;

#if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED
/* Both System V and BSD have `setpgrp' functions, but with different
Expand Down
2 changes: 1 addition & 1 deletion unix/getpgid.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <unistd.h>
#include <sys/types.h>

int __bsd_getpgrp (int pid);
__typeof__(getpgid) __getpgid;

pid_t
__getpgid (pid_t pid)
Expand Down
2 changes: 1 addition & 1 deletion unix/setpgid.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include "lib.h"

int __bsd_setpgrp (int, int);
__typeof__(setpgid) __setpgid;

int
__setpgid (pid_t pid, pid_t pgid)
Expand Down
22 changes: 1 addition & 21 deletions unix/setpgrp.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,11 @@
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <mint/mintbind.h>
#include "lib.h"

int
__setpgrp (void)
{
static short have_pgrp = 1;

if (have_pgrp) {
int r = 0;

r = Psetpgrp (0, 0);
if (r == -ENOSYS) {
have_pgrp = 0;
}
else if (r < 0) {
if (r == -ENOENT)
r = -ESRCH;
else if (r == -EACCES)
r = -EPERM;
__set_errno (-r);
return -1;
}
}

return 0;
return __bsd_setpgrp (0, 0);
}
weak_alias (__setpgrp, setpgrp)

0 comments on commit dca3288

Please sign in to comment.