Skip to content

Commit

Permalink
Daemonize follow-up fixes (ansible#81584)
Browse files Browse the repository at this point in the history
* Ensure binary data transmission in daemonize

* Add changelog fragment
  • Loading branch information
vaygr committed Sep 22, 2023
1 parent 3794612 commit 91f94fb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/81584-daemonize-follow-up-fixes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- "``ansible.module_utils.service`` - ensure binary data transmission in ``daemonize()``"
7 changes: 4 additions & 3 deletions lib/ansible/module_utils/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,10 @@ def daemonize(module, cmd):
for out in list(fds):
if out in rfd:
data = os.read(out.fileno(), chunk)
if not data:
if data:
output[out] += to_bytes(data, errors=errors)
else:
fds.remove(out)
output[out] += data
else:
break

Expand Down Expand Up @@ -248,7 +249,7 @@ def daemonize(module, cmd):
data = os.read(pipe[0], chunk)
if not data:
break
return_data += data
return_data += to_bytes(data, errors=errors)

# Note: no need to specify encoding on py3 as this module sends the
# pickle to itself (thus same python interpreter so we aren't mixing
Expand Down

0 comments on commit 91f94fb

Please sign in to comment.