smartd.cpp, popen_as_ugid.cpp: Don't use 'getdtablesize()'.

This function is declared 'legacy' since SUS 1997 and no longer part
of POSIX since 2004.  Use 'sysconf(_SC_OPEN_MAX)' instead.
This fixes build on android (GH issues/142).

git-svn-id: http://svn.code.sf.net/p/smartmontools/code/trunk@5402 4ea69e1a-61f1-4043-bf83-b5c94c648137
pull/151/head
chrfranke 2 months ago
parent ae0dd4d242
commit 3be728ebbc
  1. 7
      smartmontools/ChangeLog
  2. 2
      smartmontools/popen_as_ugid.cpp
  3. 2
      smartmontools/smartd.cpp

@ -1,5 +1,12 @@
$Id$
2022-08-06 Christian Franke <franke@computer.org>
smartd.cpp, popen_as_ugid.cpp: Don't use 'getdtablesize()'.
This function is declared 'legacy' since SUS 1997 and no longer part
of POSIX since 2004. Use 'sysconf(_SC_OPEN_MAX)' instead.
This fixes build on android (GH issues/142).
2022-08-06 themylogin <themylogin@gmail.com>
smartd.cpp: Also prevent systemd unit startup timeout in

@ -67,7 +67,7 @@ FILE * popen_as_ugid(const char * cmd, const char * mode, uid_t uid, gid_t gid)
if (!pid) { // Child
// Do not inherit any unneeded file descriptors
fclose(fp);
for (int i = 0; i < getdtablesize(); i++) {
for (int i = sysconf(_SC_OPEN_MAX); --i >= 0; ) {
if (i == pd[1] || i == sd[1])
continue;
close(i);

@ -1448,7 +1448,7 @@ static int daemon_init()
}
// close any open file descriptors
for (int i = getdtablesize(); --i >= 0; )
for (int i = sysconf(_SC_OPEN_MAX); --i >= 0; )
close(i);
// redirect any IO attempts to /dev/null and change to root directory

Loading…
Cancel
Save