Project

General

Profile

Misc #12439 ยป 0001-process.c-disable_child_handler_fork_child-simplify.patch

normalperson (Eric Wong), 05/31/2016 12:58 AM

View differences:

process.c
3497 3497
{
3498 3498
    int sig;
3499 3499
    int ret;
3500
#ifdef POSIX_SIGNAL
3501
    struct sigaction act, oact;
3502

  
3503
    act.sa_handler = SIG_DFL;
3504
    act.sa_flags = 0;
3505
    ret = sigemptyset(&act.sa_mask); /* async-signal-safe */
3506
    if (ret == -1) {
3507
        ERRMSG("sigemptyset");
3508
        return -1;
3509
    }
3510
#else
3511
    sig_t handler;
3512
#endif
3513 3500

  
3514 3501
    for (sig = 1; sig < NSIG; sig++) {
3515
        int reset = 0;
3516
#ifdef SIGPIPE
3517
        if (sig == SIGPIPE) {
3518
            reset = 1;
3519
#ifndef POSIX_SIGNAL
3520
            handler = SIG_DFL;
3521
#endif
3522
	}
3523
#endif
3524
        if (!reset) {
3525
#ifdef POSIX_SIGNAL
3526
            ret = sigaction(sig, NULL, &oact); /* async-signal-safe */
3527
            if (ret == -1 && errno == EINVAL) {
3528
                continue; /* Ignore invalid signal number. */
3529
            }
3530
            if (ret == -1) {
3531
                ERRMSG("sigaction to obtain old action");
3532
                return -1;
3533
            }
3534
            reset = (oact.sa_flags & SA_SIGINFO) ||
3535
                    (oact.sa_handler != SIG_IGN && oact.sa_handler != SIG_DFL);
3536
#else
3537
            handler = signal(sig, SIG_DFL);
3502
            sig_t handler = signal(sig, SIG_DFL);
3503

  
3538 3504
            if (handler == SIG_ERR && errno == EINVAL) {
3539 3505
                continue; /* Ignore invalid signal number */
3540 3506
            }
......
3542 3508
                ERRMSG("signal to obtain old action");
3543 3509
                return -1;
3544 3510
            }
3545
            reset = (handler != SIG_IGN && handler != SIG_DFL);
3546
#endif
3547
        }
3548
        if (reset) {
3549
#ifdef POSIX_SIGNAL
3550
            ret = sigaction(sig, &act, NULL); /* async-signal-safe */
3551
            if (ret == -1) {
3552
                ERRMSG("sigaction to set default action");
3553
                return -1;
3511
#ifdef SIGPIPE
3512
            if (sig == SIGPIPE) {
3513
                continue;
3554 3514
            }
3555
#else
3556
           handler = signal(sig, handler);
3557
           if (handler == SIG_ERR) {
3558
                ERRMSG("signal to set default action");
3559
                return -1;
3560
           }
3561 3515
#endif
3562
        }
3516
            /* it will be reset to SIG_DFL at execve time, instead */
3517
            if (handler == SIG_IGN) {
3518
                signal(sig, SIG_IGN);
3519
            }
3563 3520
    }
3564 3521

  
3565 3522
    ret = sigprocmask(SIG_SETMASK, &old->sigmask, NULL); /* async-signal-safe */