[hackers] [tabbed] restore SIGCHLD sighandler to default before spawning a program || Hiltjo Posthuma

From: <git_AT_suckless.org>
Date: Sun, 9 Apr 2023 12:48:31 +0200 (CEST)

commit 97ba13b1eb4756fb1a024fd1e83df6e393befd27
Author: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
AuthorDate: Sun Apr 9 12:47:07 2023 +0200
Commit: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
CommitDate: Sun Apr 9 12:47:07 2023 +0200

    restore SIGCHLD sighandler to default before spawning a program
    
    From sigaction(2):
    A child created via fork(2) inherits a copy of its parent's signal dispositions.
    During an execve(2), the dispositions of handled signals are reset to the default;
    the dispositions of ignored signals are left unchanged.
    
    This refused to start directly some programs from configuring in config.h:
    
    Some reported programs that didn't start were: mpv.
    
    Similar to the commit e81f17d4c196aaed6893fd4beed49991caa3e2a4 from dwm.

diff --git a/tabbed.c b/tabbed.c
index 1b61d93..81be5e4 100644
--- a/tabbed.c
+++ b/tabbed.c
_AT_@ -1088,11 +1088,19 @@ setup(void)
 void
 spawn(const Arg *arg)
 {
+ struct sigaction sa;
+
         if (fork() == 0) {
                 if(dpy)
                         close(ConnectionNumber(dpy));
 
                 setsid();
+
+ sigemptyset(&sa.sa_mask);
+ sa.sa_flags = 0;
+ sa.sa_handler = SIG_DFL;
+ sigaction(SIGCHLD, &sa, NULL);
+
                 if (arg && arg->v) {
                         execvp(((char **)arg->v)[0], (char **)arg->v);
                         fprintf(stderr, "%s: execvp %s", argv0,
Received on Sun Apr 09 2023 - 12:48:31 CEST

This archive was generated by hypermail 2.3.0 : Sun Apr 09 2023 - 13:00:38 CEST