diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2013-08-18 11:54:16 +0200 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2013-08-18 12:06:24 +0200 |
commit | 82bcfd7a4d38cd61444f871469c25c25e973798c (patch) | |
tree | 0d306026f53203a22542b60f173ce862d3bdea6c /pynslcd | |
parent | 14b93b9ebbe6a16c9ffe7be5491f56fa0c564f85 (diff) |
-n switch for pynslcd
Diffstat (limited to 'pynslcd')
-rwxr-xr-x | pynslcd/pynslcd.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/pynslcd/pynslcd.py b/pynslcd/pynslcd.py index cd3a171..73fc3cc 100755 --- a/pynslcd/pynslcd.py +++ b/pynslcd/pynslcd.py @@ -45,6 +45,9 @@ program_name = 'pynslcd' # flag to indicate whether we are in debugging mode debugging = 0 +# flag to indicate we shouldn't daemonize +nofork = False + # flag to indicate user requested the --check option checkonly = False @@ -99,6 +102,7 @@ def display_usage(fp): "Name Service LDAP connection daemon.\n" " -c, --check check if the daemon already is running\n" " -d, --debug don't fork and print debugging to stderr\n" + " -n, --nofork don't fork\n" " --help display this help and exit\n" " --version output version information and exit\n" "\n" @@ -114,8 +118,8 @@ def parse_cmdline(): program_name = sys.argv[0] or program_name try: optlist, args = getopt.gnu_getopt( - sys.argv[1:], 'cdhV', - ('check', 'debug', 'help', 'version')) + sys.argv[1:], 'cdnhV', + ('check', 'debug', 'nofork', 'help', 'version')) for flag, arg in optlist: if flag in ('-c', '--check'): global checkonly @@ -123,6 +127,9 @@ def parse_cmdline(): elif flag in ('-d', '--debug'): global debugging debugging += 1 + elif flag in ('-n', '--nofork'): + global nofork + nofork = True elif flag in ('-h', '--help'): display_usage(sys.stdout) sys.exit(0) @@ -297,7 +304,7 @@ if __name__ == '__main__': constants.NSLCD_PIDFILE) sys.exit(1) # daemonize - if debugging: + if debugging or nofork: ctx = pidfile else: ctx = daemon.DaemonContext( |