Commit eb61f834 authored by chrfranke's avatar chrfranke
Browse files

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: https://svn.code.sf.net/p/smartmontools/code/trunk@5402 4ea69e1a-61f1-4043-bf83-b5c94c648137
parent 5743a9da
$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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment