summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAbhijeet Kasurde <akasurde@redhat.com>2024-10-15 16:59:01 +0200
committerGitHub <noreply@github.com>2024-10-15 16:59:01 +0200
commit671c797aa1b2a0b68d3109e94078f5854860683d (patch)
tree64432fa9c1f381c3ca6d5951dd45f7e5a1b9319b
parentfeat: checksum_algo param for find module (#83014) (diff)
downloadansible-671c797aa1b2a0b68d3109e94078f5854860683d.tar.xz
ansible-671c797aa1b2a0b68d3109e94078f5854860683d.zip
Remove unnecessary code (#84085)
* os.setsid does not return anything, so remove code which relying on return value Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
-rw-r--r--lib/ansible/module_utils/service.py8
1 files changed, 2 insertions, 6 deletions
diff --git a/lib/ansible/module_utils/service.py b/lib/ansible/module_utils/service.py
index d98c56e913..6d3ecea4b8 100644
--- a/lib/ansible/module_utils/service.py
+++ b/lib/ansible/module_utils/service.py
@@ -147,9 +147,7 @@ def fork_process():
os._exit(0)
# get new process session and detach
- sid = os.setsid()
- if sid == -1:
- raise Exception("Unable to detach session while daemonizing")
+ os.setsid()
# avoid possible problems with cwd being removed
os.chdir("/")
@@ -181,10 +179,8 @@ def daemonize(module, cmd):
try:
pipe = os.pipe()
pid = fork_process()
- except OSError:
+ except (OSError, RuntimeError):
module.fail_json(msg="Error while attempting to fork: %s", exception=traceback.format_exc())
- except Exception as exc:
- module.fail_json(msg=to_text(exc), exception=traceback.format_exc())
# we don't do any locking as this should be a unique module/process
if pid == 0: