use os._exit instead of sys.exit when daemonizing

According to the docs [here](https://docs.python.org/3/library/os.html#os._exit)

> `os._exit` should should normally only be used in the child process after a fork().

This will exit the process with status n, without calling cleanup
handlers, flushing stdio buffers, etc.

Fixes saltstack/salt-jenkins#1075
This commit is contained in:
Daniel Wallace 2018-08-23 19:05:55 -05:00
parent 158c1ca575
commit e06ce49c1b
No known key found for this signature in database
GPG key ID: 5FA5E5544F010D48

View file

@ -71,7 +71,7 @@ def daemonize(redirect_out=True):
if pid > 0:
# exit first parent
salt.utils.crypt.reinit_crypto()
sys.exit(salt.defaults.exitcodes.EX_OK)
os._exit(salt.defaults.exitcodes.EX_OK)
except OSError as exc:
log.error('fork #1 failed: %s (%s)', exc.errno, exc)
sys.exit(salt.defaults.exitcodes.EX_GENERIC)