From 670f66a5e1804519e1e1b4554915b7c7da6b72b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luc=C3=ADa=20Andrea=20Illanes=20Albornoz?= Date: Sat, 18 Mar 2023 09:56:28 +0100 Subject: Safely send dispatcher messages. --- subr.ex/ex_pkg_dispatch.subr | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'subr.ex/ex_pkg_dispatch.subr') diff --git a/subr.ex/ex_pkg_dispatch.subr b/subr.ex/ex_pkg_dispatch.subr index 1274aa64..217bd360 100644 --- a/subr.ex/ex_pkg_dispatch.subr +++ b/subr.ex/ex_pkg_dispatch.subr @@ -380,4 +380,23 @@ ex_pkg_dispatch() { return "${_epd_rc}"; }; +# +# ex_pkg_dipatch_send() - send message from dispatcher child process to dispatcher parent process across FIFO +# @_op: message operation string +# +# Return: zero (0) invariably. +# +ex_pkg_dispatch_send() { + local _epds_op="${1}"; + shift 1; + + trap '' PIPE; + while ! printf "%s%s\n" "${_epds_op}" "${*:+ "${*}"}" 1>&3 2>/dev/null; do + :; + done; + trap - PIPE; + + return 0; +}; + # vim:filetype=sh textwidth=0 -- cgit v1.2.3