chiark / gitweb /
execute: explain in a comment, why close_all_fds() is invoked the second time differently
[elogind.git] / src / core / execute.c
index d8452a666c490ae0b9cda8900fcbb839edd4644a..b5b22472d5a9f8ff954ad409484e4cef7aaedca8 100644 (file)
@@ -1635,7 +1635,9 @@ int exec_spawn(ExecCommand *command,
                 }
 
                 /* We repeat the fd closing here, to make sure that
-                 * nothing is leaked from the PAM modules */
+                 * nothing is leaked from the PAM modules. Note that
+                 * we are more aggressive this time since socket_fd
+                 * and the netns fds we don#t need anymore. */
                 err = close_all_fds(fds, n_fds);
                 if (err >= 0)
                         err = shift_fds(fds, n_fds);
@@ -2398,12 +2400,11 @@ void exec_status_dump(ExecStatus *s, FILE *f, const char *prefix) {
         assert(s);
         assert(f);
 
-        if (!prefix)
-                prefix = "";
-
         if (s->pid <= 0)
                 return;
 
+        prefix = strempty(prefix);
+
         fprintf(f,
                 "%sPID: "PID_FMT"\n",
                 prefix, s->pid);
@@ -2463,21 +2464,16 @@ char *exec_command_line(char **argv) {
 }
 
 void exec_command_dump(ExecCommand *c, FILE *f, const char *prefix) {
-        _cleanup_free_ char *p2 = NULL;
-        const char *prefix2;
-
         _cleanup_free_ char *cmd = NULL;
+        const char *prefix2;
 
         assert(c);
         assert(f);
 
-        if (!prefix)
-                prefix = "";
-        p2 = strappend(prefix, "\t");
-        prefix2 = p2 ? p2 : prefix;
+        prefix = strempty(prefix);
+        prefix2 = strappenda(prefix, "\t");
 
         cmd = exec_command_line(c->argv);
-
         fprintf(f,
                 "%sCommand Line: %s\n",
                 prefix, cmd ? cmd : strerror(ENOMEM));
@@ -2488,8 +2484,7 @@ void exec_command_dump(ExecCommand *c, FILE *f, const char *prefix) {
 void exec_command_dump_list(ExecCommand *c, FILE *f, const char *prefix) {
         assert(f);
 
-        if (!prefix)
-                prefix = "";
+        prefix = strempty(prefix);
 
         LIST_FOREACH(command, c, c)
                 exec_command_dump(c, f, prefix);