summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-05-03 14:08:31 +0200
committerThomas Haller <thaller@redhat.com>2015-05-05 16:39:17 +0200
commitca4361bd5388a242f232dfa2caea60e5770fef30 (patch)
tree3f1de209a38aef2e80a3f73be2f5e8a96a57c2ac
parentaa5cfdd7e19c90846fec2e84efad9374dc22998e (diff)
downloadNetworkManager-ca4361bd5388a242f232dfa2caea60e5770fef30.tar.gz
utils: preserve errno in nm_utils_kill_child_sync()
-rw-r--r--src/NetworkManagerUtils.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/NetworkManagerUtils.c b/src/NetworkManagerUtils.c
index ae2e83e482..82c872175e 100644
--- a/src/NetworkManagerUtils.c
+++ b/src/NetworkManagerUtils.c
@@ -624,13 +624,15 @@ _sleep_duration_convert_ms_to_us (guint32 sleep_duration_msec)
* sent unless the child already exited. If the child does not exit within @wait_before_kill_msec milliseconds,
* the function will send %SIGKILL and waits for the child indefinitly. If @wait_before_kill_msec is zero, no
* %SIGKILL signal will be sent.
+ *
+ * In case of error, errno is preserved to contain the last reason of failure.
**/
gboolean
nm_utils_kill_child_sync (pid_t pid, int sig, guint64 log_domain, const char *log_name,
int *child_status, guint32 wait_before_kill_msec,
guint32 sleep_duration_msec)
{
- int status = 0, errsv;
+ int status = 0, errsv = 0;
pid_t ret;
gboolean success = FALSE;
gboolean was_waiting = FALSE, send_kill = FALSE;
@@ -776,6 +778,7 @@ nm_utils_kill_child_sync (pid_t pid, int sig, guint64 log_domain, const char *lo
out:
if (child_status)
*child_status = success ? status : -1;
+ errno = success ? 0 : errsv;
return success;
}