Skip to content

Commit

Permalink
Remove getdtablesize calls in favor of sysconf(_SC_OPEN_MAX).
Browse files Browse the repository at this point in the history
`getdtablesize()` has long been deprecated in favor of
`sysconf(_SC_OPEN_MAX)`.
  • Loading branch information
waywardmonkeys committed Dec 14, 2020
1 parent 2dba749 commit 92f36cf
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 10 deletions.
4 changes: 0 additions & 4 deletions src/unixcomm.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,7 @@ int FindUnixPipes(void) {
if ((envtmp = getenv("LDEUNIXPID"))) UnixPID = atoi(envtmp);

/* This is a good place to initialize stuff like the UJ table */
#ifdef SYSVONLY
NPROCS = sysconf(_SC_OPEN_MAX);
#else
NPROCS = getdtablesize();
#endif /* SYSVONLY */

UJ = (struct unixjob *)malloc(NPROCS * sizeof(struct unixjob));
cleareduj.status = -1;
Expand Down
7 changes: 1 addition & 6 deletions src/unixfork.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,13 +454,8 @@ int fork_Unix() {
dup2(sock, 1);
dup2(sock, 2);

#ifdef SYSVONLY
/* Make sure everything else is closed POSIX has no getdtab... */
/* Make sure everything else is closed. */
for (i = 3; i < sysconf(_SC_OPEN_MAX); i++) close(i);
#else
/* Make sure everything else is closed */
for (i = 3; i < getdtablesize(); i++) close(i);
#endif /* SYSVONLY */

/* Run the shell command and get the result */
status = system(cmdstring);
Expand Down

0 comments on commit 92f36cf

Please sign in to comment.