Sign In
Sign Up
Search is temporarily disabled. See
ticket
for more info.
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
List overview
Download
lvm2-commits
August 2017
----- 2024 -----
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
lvm2-commits@lists.fedorahosted.org
5 participants
50 discussions
Start a n
N
ew thread
master - lvmlockd: fix check for no running lock manager
by David Teigland
29 Aug '17
29 Aug '17
Gitweb:
https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=09c792c20667aa8d7fb27…
Commit: 09c792c20667aa8d7fb2799e484d913a5eb8a147 Parent: f847fcd31a41f61dd81b30ac91f3e2720088b8f2 Author: David Teigland <teigland(a)redhat.com> AuthorDate: Tue Aug 29 15:18:12 2017 -0500 Committer: David Teigland <teigland(a)redhat.com> CommitterDate: Tue Aug 29 15:18:12 2017 -0500 lvmlockd: fix check for no running lock manager In some cases it was reporting there was no running lock manager when there is. --- daemons/lvmlockd/lvmlockd-core.c | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-) diff --git a/daemons/lvmlockd/lvmlockd-core.c b/daemons/lvmlockd/lvmlockd-core.c index f9d07c1..a921140 100644 --- a/daemons/lvmlockd/lvmlockd-core.c +++ b/daemons/lvmlockd/lvmlockd-core.c @@ -3676,7 +3676,17 @@ static int client_send_result(struct client *cl, struct action *act) if (!gl_lsname_dlm[0]) strcat(result_flags, "NO_GL_LS,"); } else { - strcat(result_flags, "NO_GL_LS,NO_LM"); + int found_lm = 0; + + if (lm_support_dlm() && lm_is_running_dlm()) + found_lm++; + if (lm_support_sanlock() && lm_is_running_sanlock()) + found_lm++; + + if (!found_lm) + strcat(result_flags, "NO_GL_LS,NO_LM"); + else + strcat(result_flags, "NO_GL_LS"); } }
1
0
0
0
master - lvmlockd: print error about starting lock manager
by David Teigland
28 Aug '17
28 Aug '17
Gitweb:
https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f847fcd31a41f61dd81b3…
Commit: f847fcd31a41f61dd81b30ac91f3e2720088b8f2 Parent: c8fdc5c0877b137ed3ca1f217d8ef0fa89299a9a Author: David Teigland <teigland(a)redhat.com> AuthorDate: Mon Aug 28 16:24:00 2017 -0500 Committer: David Teigland <teigland(a)redhat.com> CommitterDate: Mon Aug 28 16:24:00 2017 -0500 lvmlockd: print error about starting lock manager In the case where lvmlockd is running, but no lock manager is running, we should print a specific error message about that situation. --- daemons/lvmlockd/lvmlockd-core.c | 2 +- lib/locking/lvmlockd.c | 10 ++++++++++ lib/locking/lvmlockd.h | 1 + 3 files changed, 12 insertions(+), 1 deletions(-) diff --git a/daemons/lvmlockd/lvmlockd-core.c b/daemons/lvmlockd/lvmlockd-core.c index 903da7c..f9d07c1 100644 --- a/daemons/lvmlockd/lvmlockd-core.c +++ b/daemons/lvmlockd/lvmlockd-core.c @@ -3676,7 +3676,7 @@ static int client_send_result(struct client *cl, struct action *act) if (!gl_lsname_dlm[0]) strcat(result_flags, "NO_GL_LS,"); } else { - strcat(result_flags, "NO_GL_LS,"); + strcat(result_flags, "NO_GL_LS,NO_LM"); } } diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c index d85021c..a0e3f03 100644 --- a/lib/locking/lvmlockd.c +++ b/lib/locking/lvmlockd.c @@ -115,6 +115,9 @@ static void _flags_str_to_lockd_flags(const char *flags_str, uint32_t *lockd_fla if (strstr(flags_str, "NO_GL_LS")) *lockd_flags |= LD_RF_NO_GL_LS; + if (strstr(flags_str, "NO_LM")) + *lockd_flags |= LD_RF_NO_LM; + if (strstr(flags_str, "DUP_GL_LS")) *lockd_flags |= LD_RF_DUP_GL_LS; @@ -1362,6 +1365,9 @@ int lockd_gl_create(struct cmd_context *cmd, const char *def_mode, const char *v log_error("Global lock failed: check that VG holding global lock exists and is started."); else log_error("Global lock failed: check that global lockspace is started."); + + if (lockd_flags & LD_RF_NO_LM) + log_error("Start a lock manager, lvmlockd did not find one running."); return 0; } @@ -1565,6 +1571,9 @@ int lockd_gl(struct cmd_context *cmd, const char *def_mode, uint32_t flags) * access to lease storage. */ + if (result == -ENOLS && (lockd_flags & LD_RF_NO_LM)) + log_error("Start a lock manager, lvmlockd did not find one running."); + if (result == -ENOLS || result == -ESTARTING || result == -EVGKILLED || @@ -1583,6 +1592,7 @@ int lockd_gl(struct cmd_context *cmd, const char *def_mode, uint32_t flags) log_error("Global lock failed: storage failed for sanlock leases"); else log_error("Global lock failed: error %d", result); + return 0; } diff --git a/lib/locking/lvmlockd.h b/lib/locking/lvmlockd.h index 8b282d8..cf23e9b 100644 --- a/lib/locking/lvmlockd.h +++ b/lib/locking/lvmlockd.h @@ -28,6 +28,7 @@ #define LD_RF_NO_GL_LS 0x00000002 #define LD_RF_WARN_GL_REMOVED 0x00000004 #define LD_RF_DUP_GL_LS 0x00000008 +#define LD_RF_NO_LM 0x00000010 /* lockd_state flags */ #define LDST_EX 0x00000001
1
0
0
0
master - cleanup: easier to read code
by Zdenek Kabelac
25 Aug '17
25 Aug '17
Gitweb:
https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=c8fdc5c0877b137ed3ca1…
Commit: c8fdc5c0877b137ed3ca1f217d8ef0fa89299a9a Parent: 962874bfe2a3c3511e42fe29f0f013c780f65e63 Author: Zdenek Kabelac <zkabelac(a)redhat.com> AuthorDate: Fri Aug 25 11:53:26 2017 +0200 Committer: Zdenek Kabelac <zkabelac(a)redhat.com> CommitterDate: Fri Aug 25 14:20:59 2017 +0200 cleanup: easier to read code Split into lines for better reading. --- daemons/clvmd/clvmd-command.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/daemons/clvmd/clvmd-command.c b/daemons/clvmd/clvmd-command.c index cf19dc2..2971ecb 100644 --- a/daemons/clvmd/clvmd-command.c +++ b/daemons/clvmd/clvmd-command.c @@ -171,8 +171,10 @@ int do_command(struct local_client *client, struct clvm_header *msg, int msglen, /* Check the status of the command and return the error text */ if (status) { - *retlen = 1 + ((*buf) ? dm_snprintf(*buf, buflen, "%s", - strerror(status)) : -1); + if (*buf) + *retlen = dm_snprintf(*buf, buflen, "%s", strerror(status)) + 1; + else + *retlen = 0; } return status;
1
0
0
0
master - dmsetup: validate strtol reading
by Zdenek Kabelac
25 Aug '17
25 Aug '17
Gitweb:
https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=962874bfe2a3c3511e42f…
Commit: 962874bfe2a3c3511e42fe29f0f013c780f65e63 Parent: 47b7d4a7336fa60eb25ad15b2fc3fcb5b96ce1c2 Author: Zdenek Kabelac <zkabelac(a)redhat.com> AuthorDate: Fri Aug 25 11:48:17 2017 +0200 Committer: Zdenek Kabelac <zkabelac(a)redhat.com> CommitterDate: Fri Aug 25 14:20:59 2017 +0200 dmsetup: validate strtol reading Better validation for --mode option. --- tools/dmsetup.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/tools/dmsetup.c b/tools/dmsetup.c index 341522c..d9532fb 100644 --- a/tools/dmsetup.c +++ b/tools/dmsetup.c @@ -7054,7 +7054,13 @@ static int _process_switches(int *argcp, char ***argvp, const char *dev_dir) if (c == 'M' || ind == MODE_ARG) { _switches[MODE_ARG]++; /* FIXME Accept modes as per chmod */ - _int_args[MODE_ARG] = (int) strtol(optarg, NULL, 8); + errno = 0; + _int_args[MODE_ARG] = (int) strtol(optarg, &s, 8); + if (errno || !s || *s || !_int_args[MODE_ARG]) { + log_error("Invalid argument for --mode: %s. %s", + optarg, errno ? strerror(errno) : ""); + return 0; + } } if (ind == DEFERRED_ARG) _switches[DEFERRED_ARG]++;
1
0
0
0
master - dmsetup: add missing -- for option
by Zdenek Kabelac
25 Aug '17
25 Aug '17
Gitweb:
https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=47b7d4a7336fa60eb25ad…
Commit: 47b7d4a7336fa60eb25ad15b2fc3fcb5b96ce1c2 Parent: 26d97f179fabe0669dc10e7e16398803c323ca93 Author: Zdenek Kabelac <zkabelac(a)redhat.com> AuthorDate: Fri Aug 25 11:47:36 2017 +0200 Committer: Zdenek Kabelac <zkabelac(a)redhat.com> CommitterDate: Fri Aug 25 14:20:59 2017 +0200 dmsetup: add missing -- for option --- tools/dmsetup.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/tools/dmsetup.c b/tools/dmsetup.c index 0fd2f2c..341522c 100644 --- a/tools/dmsetup.c +++ b/tools/dmsetup.c @@ -6157,7 +6157,7 @@ static struct command _dmsetup_commands[] = { {"create", "<dev_name>\n" "\t [-j|--major <major> -m|--minor <minor>]\n" "\t [-U|--uid <uid>] [-G|--gid <gid>] [-M|--mode <octal_mode>]\n" - "\t [-u|uuid <uuid>] [--addnodeonresume|--addnodeoncreate]\n" + "\t [-u|--uuid <uuid>] [--addnodeonresume|--addnodeoncreate]\n" "\t [--readahead {[+]<sectors>|auto|none}]\n" "\t [-n|--notable|--table {<table>|<table_file>}]\n" "\tcreate --concise [<concise_device_spec_list>]", 0, 2, 0, 0, _create},
1
0
0
0
master - reporting: validate time parsing with strtol
by Zdenek Kabelac
25 Aug '17
25 Aug '17
Gitweb:
https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=26d97f179fabe0669dc10…
Commit: 26d97f179fabe0669dc10e7e16398803c323ca93 Parent: d79d9193298b04246c18dcacd8b372518eb10ffc Author: Zdenek Kabelac <zkabelac(a)redhat.com> AuthorDate: Fri Aug 25 11:58:33 2017 +0200 Committer: Zdenek Kabelac <zkabelac(a)redhat.com> CommitterDate: Fri Aug 25 14:20:59 2017 +0200 reporting: validate time parsing with strtol Check for out-of-range numbers being result of strtol parsing. --- lib/report/report.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/lib/report/report.c b/lib/report/report.c index 89110f0..c32df71 100644 --- a/lib/report/report.c +++ b/lib/report/report.c @@ -898,7 +898,12 @@ static int _translate_time_items(struct dm_report *rh, struct time_info *info, id = ti->prop->id; if (_is_time_num(id)) { + errno = 0; num = strtol(ti->s, &end, 10); + if (errno) { + log_error("_translate_time_items: invalid time."); + return 0; + } switch (id) { case TIME_NUM_MULTIPLIER_NEGATIVE: multiplier = -num;
1
0
0
0
master - lvmlockd: log pthread_join errno code
by Zdenek Kabelac
25 Aug '17
25 Aug '17
Gitweb:
https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=d79d9193298b04246c18d…
Commit: d79d9193298b04246c18dcacd8b372518eb10ffc Parent: da9a8fdedc25645706ae198bad098f366351db58 Author: Zdenek Kabelac <zkabelac(a)redhat.com> AuthorDate: Fri Aug 25 11:52:09 2017 +0200 Committer: Zdenek Kabelac <zkabelac(a)redhat.com> CommitterDate: Fri Aug 25 14:20:59 2017 +0200 lvmlockd: log pthread_join errno code Log possible errno with pthread_join (and one close() instance). --- daemons/lvmlockd/lvmlockd-core.c | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-) diff --git a/daemons/lvmlockd/lvmlockd-core.c b/daemons/lvmlockd/lvmlockd-core.c index 253d86b..903da7c 100644 --- a/daemons/lvmlockd/lvmlockd-core.c +++ b/daemons/lvmlockd/lvmlockd-core.c @@ -3539,11 +3539,15 @@ static int setup_worker_thread(void) static void close_worker_thread(void) { + int perrno; + pthread_mutex_lock(&worker_mutex); worker_stop = 1; pthread_cond_signal(&worker_cond); pthread_mutex_unlock(&worker_mutex); - pthread_join(worker_thread, NULL); + + if ((perrno = pthread_join(worker_thread, NULL))) + log_error("pthread_join worker_thread error %d", perrno); } /* client_mutex is locked */ @@ -3769,7 +3773,8 @@ static int client_send_result(struct client *cl, struct action *act) if (dump_fd >= 0) { /* To avoid deadlock, send data here after the reply. */ send_dump_buf(dump_fd, dump_len); - close(dump_fd); + if (close(dump_fd)) + log_error("failed to close dump socket %d", dump_fd); } return rv; @@ -4786,11 +4791,15 @@ static int setup_client_thread(void) static void close_client_thread(void) { + int perrno; + pthread_mutex_lock(&client_mutex); client_stop = 1; pthread_cond_signal(&client_cond); pthread_mutex_unlock(&client_mutex); - pthread_join(client_thread, NULL); + + if ((perrno = pthread_join(client_thread, NULL))) + log_error("pthread_join client_thread error %d", perrno); } /*
1
0
0
0
master - lvmlockctl: fix check for failing close
by Zdenek Kabelac
25 Aug '17
25 Aug '17
Gitweb:
https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=da9a8fdedc25645706ae1…
Commit: da9a8fdedc25645706ae198bad098f366351db58 Parent: 288e10cf8b990cd740fba409d6f20525209f4f43 Author: Zdenek Kabelac <zkabelac(a)redhat.com> AuthorDate: Fri Aug 25 11:57:49 2017 +0200 Committer: Zdenek Kabelac <zkabelac(a)redhat.com> CommitterDate: Fri Aug 25 14:20:59 2017 +0200 lvmlockctl: fix check for failing close On close() failure it's -1. --- daemons/lvmlockd/lvmlockctl.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/daemons/lvmlockd/lvmlockctl.c b/daemons/lvmlockd/lvmlockctl.c index 7d4e072..436221d 100644 --- a/daemons/lvmlockd/lvmlockctl.c +++ b/daemons/lvmlockd/lvmlockctl.c @@ -379,7 +379,7 @@ static int setup_dump_socket(void) rv = bind(s, (struct sockaddr *) &dump_addr, dump_addrlen); if (rv < 0) { rv = -errno; - if (!close(s)) + if (close(s)) log_error("failed to close dump socket"); return rv; }
1
0
0
0
master - lvmlockd: avoid double unlock of client_mutex
by Zdenek Kabelac
25 Aug '17
25 Aug '17
Gitweb:
https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=288e10cf8b990cd740fba…
Commit: 288e10cf8b990cd740fba409d6f20525209f4f43 Parent: b3b1e788e16c77f6784f30b8e984f68792f8fa1a Author: Zdenek Kabelac <zkabelac(a)redhat.com> AuthorDate: Fri Aug 25 14:07:45 2017 +0200 Committer: Zdenek Kabelac <zkabelac(a)redhat.com> CommitterDate: Fri Aug 25 14:20:59 2017 +0200 lvmlockd: avoid double unlock of client_mutex Avoid double unlocking of client_mutex and and unlock client_mutex in 'else' branch since it's already unlocked in 'if (cl->dead)' branch. --- WHATS_NEW | 1 + daemons/lvmlockd/lvmlockd-core.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index ac69c16..32bbc41 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.174 - ================================= + Avoid double unlocking of client & lockspace mutexes in lvmlockd. Fix leaking of file descriptor for non-blocking filebased locking. Fix check for 2nd mda at end of disk fits if using pvcreate --restorefile. Use maximum metadataarea size that fits with pvcreate --restorefile. diff --git a/daemons/lvmlockd/lvmlockd-core.c b/daemons/lvmlockd/lvmlockd-core.c index 36d84e2..253d86b 100644 --- a/daemons/lvmlockd/lvmlockd-core.c +++ b/daemons/lvmlockd/lvmlockd-core.c @@ -4761,8 +4761,8 @@ static void *client_thread_main(void *arg_in) } else { pthread_mutex_unlock(&cl->mutex); } - } - pthread_mutex_unlock(&client_mutex); + } else + pthread_mutex_unlock(&client_mutex); } out: return NULL;
1
0
0
0
master - daemonize: more unified code
by Zdenek Kabelac
25 Aug '17
25 Aug '17
Gitweb:
https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b3b1e788e16c77f6784f3…
Commit: b3b1e788e16c77f6784f30b8e984f68792f8fa1a Parent: 5de944420224f3b629e843f9c190132ed9ff3dca Author: Zdenek Kabelac <zkabelac(a)redhat.com> AuthorDate: Fri Aug 25 11:55:38 2017 +0200 Committer: Zdenek Kabelac <zkabelac(a)redhat.com> CommitterDate: Fri Aug 25 14:20:57 2017 +0200 daemonize: more unified code ATM we have several instances of daemonizing code. Each has its 'special' logic so not completely easy to unify them all into a single routine. Start to unify them and use one strategy for rediricting all input/outpus to /dev/null - use 'dup2' function for this and open /dev/null before fork to make sure it's available. --- daemons/clvmd/clvmd.c | 26 ++++++++++---------------- libdaemon/server/daemon-server.c | 21 +++++++++++++++------ 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/daemons/clvmd/clvmd.c b/daemons/clvmd/clvmd.c index 79aa939..46f5f44 100644 --- a/daemons/clvmd/clvmd.c +++ b/daemons/clvmd/clvmd.c @@ -1105,31 +1105,25 @@ static void be_daemon(int timeout) break; default: /* Parent */ + (void) close(devnull); (void) close(child_pipe[1]); - wait_for_child(child_pipe[0], timeout); + wait_for_child(child_pipe[0], timeout); /* noreturn */ } /* Detach ourself from the calling environment */ - if (close(0) || close(1) || close(2)) { - perror("Error closing terminal FDs"); - exit(4); - } - setsid(); + (void) dup2(devnull, STDIN_FILENO); + (void) dup2(devnull, STDOUT_FILENO); + (void) dup2(devnull, STDERR_FILENO); + + if (devnull > STDERR_FILENO) + (void) close(devnull); - if (dup2(devnull, 0) < 0 || dup2(devnull, 1) < 0 - || dup2(devnull, 2) < 0) { - perror("Error setting terminal FDs to /dev/null"); - log_error("Error setting terminal FDs to /dev/null: %m"); - exit(5); - } - if ((devnull > STDERR_FILENO) && close(devnull)) { - log_sys_error("close", "/dev/null"); - exit(7); - } if (chdir("/")) { log_error("Error setting current directory to /: %m"); exit(6); } + + setsid(); } static int verify_message(char *buf, int len) diff --git a/libdaemon/server/daemon-server.c b/libdaemon/server/daemon-server.c index 6fdf195..0950c2e 100644 --- a/libdaemon/server/daemon-server.c +++ b/libdaemon/server/daemon-server.c @@ -334,6 +334,11 @@ static void _daemonise(daemon_state s) struct timeval tval; sigset_t my_sigset; + if ((fd = open("/dev/null", O_RDWR)) == -1) { + fprintf(stderr, "Unable to open /dev/null.\n"); + exit(EXIT_FAILURE); + } + sigemptyset(&my_sigset); if (sigprocmask(SIG_SETMASK, &my_sigset, NULL) < 0) { fprintf(stderr, "Unable to restore signals.\n"); @@ -350,6 +355,7 @@ static void _daemonise(daemon_state s) break; default: + (void) close(fd); /* Wait for response from child */ while (!waitpid(pid, &child_status, WNOHANG) && !_shutdown_requested) { tval.tv_sec = 0; @@ -374,12 +380,20 @@ static void _daemonise(daemon_state s) if (chdir("/")) exit(1); + (void) dup2(fd, STDIN_FILENO); + (void) dup2(fd, STDOUT_FILENO); + (void) dup2(fd, STDERR_FILENO); + + if (fd > STDERR_FILENO) + (void) close(fd); + + /* Switch to sysconf(_SC_OPEN_MAX) ?? */ if (getrlimit(RLIMIT_NOFILE, &rlim) < 0) fd = 256; /* just have to guess */ else fd = rlim.rlim_cur; - for (--fd; fd >= 0; fd--) { + for (--fd; fd > STDERR_FILENO; fd--) { #ifdef __linux__ /* Do not close fds preloaded by systemd! */ if (_systemd_activation && fd == SD_FD_SOCKET_SERVER) @@ -388,11 +402,6 @@ static void _daemonise(daemon_state s) (void) close(fd); } - if ((open("/dev/null", O_RDONLY) < 0) || - (open("/dev/null", O_WRONLY) < 0) || - (open("/dev/null", O_WRONLY) < 0)) - exit(1); - setsid(); }
1
0
0
0
← Newer
1
2
3
4
5
Older →
Jump to page:
1
2
3
4
5
Results per page:
10
25
50
100
200