chiark / gitweb /
tree-wide: drop 'This file is part of systemd' blurb
[elogind.git] / src / libelogind / sd-bus / bus-container.c
index a1242c5678b0e78e7d66873a8bcc8aa4b93f5780..47691960a9589632bf3b5ef40f3372b8e30db14d 100644 (file)
@@ -1,21 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 /***
-  This file is part of systemd.
-
   Copyright 2013 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
 #include <fcntl.h>
@@ -31,9 +16,8 @@
 int bus_container_connect_socket(sd_bus *b) {
         _cleanup_close_pair_ int pair[2] = { -1, -1 };
         _cleanup_close_ int pidnsfd = -1, mntnsfd = -1, usernsfd = -1, rootfd = -1;
-        pid_t child;
-        siginfo_t si;
         int r, error_buf = 0;
+        pid_t child;
         ssize_t n;
 
         assert(b);
@@ -55,6 +39,8 @@ int bus_container_connect_socket(sd_bus *b) {
         if (b->input_fd < 0)
                 return -errno;
 
+        b->input_fd = fd_move_above_stdio(b->input_fd);
+
         b->output_fd = b->input_fd;
 
         bus_socket_setup(b);
@@ -97,21 +83,20 @@ int bus_container_connect_socket(sd_bus *b) {
                         _exit(EXIT_SUCCESS);
                 }
 
-                r = wait_for_terminate(grandchild, &si);
+                r = wait_for_terminate_and_check("(sd-buscntr2)", grandchild, 0);
                 if (r < 0)
                         _exit(EXIT_FAILURE);
 
-                if (si.si_code != CLD_EXITED)
-                        _exit(EXIT_FAILURE);
-
-                _exit(si.si_status);
+                _exit(r);
         }
 
         pair[1] = safe_close(pair[1]);
 
-        r = wait_for_terminate(child, &si);
+        r = wait_for_terminate_and_check("(sd-buscntr)", child, 0);
         if (r < 0)
                 return r;
+        if (r != EXIT_SUCCESS)
+                return -EPROTO;
 
         n = read(pair[0], &error_buf, sizeof(error_buf));
         if (n < 0)
@@ -131,11 +116,5 @@ int bus_container_connect_socket(sd_bus *b) {
                         return -error_buf;
         }
 
-        if (si.si_code != CLD_EXITED)
-                return -EIO;
-
-        if (si.si_status != EXIT_SUCCESS)
-                return -EIO;
-
         return bus_socket_start_auth(b);
 }