~ubuntu-branches/ubuntu/trusty/debian-installer-utils/trusty-proposed

« back to all changes in this revision

Viewing changes to log-output.c

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2012-07-20 17:12:34 UTC
  • Revision ID: package-import@ubuntu.com-20120720171234-3p4rxk8tmy79uxlp
Tags: 1.91ubuntu2
log-output: Always install a no-op SIGCHLD handler, in case the
subsidiary process starts a daemon which does not fully disconnect its
standard file descriptors (LP: #1021293).  See also the changelog for
1.36ubuntu2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
                { "pass-stdout", no_argument, &pass_stdout, 1 },
66
66
                { NULL, 0, NULL, 0 }
67
67
        };
 
68
        struct sigaction sa;
68
69
        di_io_handler *stdout_handler = NULL, *stderr_handler = NULL;
69
70
        di_process_handler *parent_prepare_handler = NULL;
70
71
        di_process_handler *child_prepare_handler = NULL;
94
95
        if (!argv[optind])
95
96
                return 0;
96
97
 
 
98
        /* It's possible for subsidiary processes to start daemons which
 
99
         * forget to clean up their file descriptors properly, which means
 
100
         * that polling the other ends of those file descriptors will never
 
101
         * complete.  We install a no-op SIGCHLD handler to make sure that
 
102
         * its poll() gets EINTR and gives up.
 
103
         *
 
104
         * Technically, this is exploiting a bug in di_exec, and a better
 
105
         * solution would be nice ...
 
106
         */
 
107
        sa.sa_handler = &sigchld_handler;
 
108
        sigemptyset(&sa.sa_mask);
 
109
        sa.sa_flags = SA_NOCLDSTOP;
 
110
        sigaction(SIGCHLD, &sa, NULL);
 
111
 
97
112
        if (pass_stdout) {
98
 
                /* di_exec is a bit odd, and won't always notice that the
99
 
                 * subsidiary process has gone away if a stdout_handler
100
 
                 * isn't installed. We install a no-op SIGCHLD handler to
101
 
                 * make sure that its poll() gets EINTR and gives up.
102
 
                 *
103
 
                 * Technically, this is exploiting a bug in di_exec, and a
104
 
                 * better solution would be nice ...
105
 
                 */
106
 
                struct sigaction sa;
107
 
                sa.sa_handler = &sigchld_handler;
108
 
                sigemptyset(&sa.sa_mask);
109
 
                sa.sa_flags = SA_NOCLDSTOP;
110
 
                sigaction(SIGCHLD, &sa, NULL);
111
 
 
112
113
                orig_stdout = dup(1);
113
114
                parent_prepare_handler = &close_orig_stdout;
114
115
                child_prepare_handler = &restore_orig_stdout;