mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
generic sighandler
This commit is contained in:
parent
140f8b9eba
commit
977992626a
15
calmwm.c
15
calmwm.c
@ -48,7 +48,7 @@ struct conf Conf;
|
|||||||
const char *homedir;
|
const char *homedir;
|
||||||
volatile sig_atomic_t cwm_status;
|
volatile sig_atomic_t cwm_status;
|
||||||
|
|
||||||
static void sigchld_cb(int);
|
static void sighdlr(int);
|
||||||
static int x_errorhandler(Display *, XErrorEvent *);
|
static int x_errorhandler(Display *, XErrorEvent *);
|
||||||
static void x_init(const char *);
|
static void x_init(const char *);
|
||||||
static void x_restart(char **);
|
static void x_restart(char **);
|
||||||
@ -84,7 +84,7 @@ main(int argc, char **argv)
|
|||||||
argc -= optind;
|
argc -= optind;
|
||||||
argv += optind;
|
argv += optind;
|
||||||
|
|
||||||
if (signal(SIGCHLD, sigchld_cb) == SIG_ERR)
|
if (signal(SIGCHLD, sighdlr) == SIG_ERR)
|
||||||
err(1, "signal");
|
err(1, "signal");
|
||||||
|
|
||||||
if ((homedir = getenv("HOME")) == NULL || *homedir == '\0') {
|
if ((homedir = getenv("HOME")) == NULL || *homedir == '\0') {
|
||||||
@ -205,16 +205,19 @@ x_errorhandler(Display *dpy, XErrorEvent *e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sigchld_cb(int which)
|
sighdlr(int sig)
|
||||||
{
|
{
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
int save_errno = errno;
|
int save_errno = errno, status;
|
||||||
int status;
|
|
||||||
|
|
||||||
|
switch (sig) {
|
||||||
|
case SIGCHLD:
|
||||||
/* Collect dead children. */
|
/* Collect dead children. */
|
||||||
while ((pid = waitpid(-1, &status, WNOHANG)) > 0 ||
|
while ((pid = waitpid(WAIT_ANY, &status, WNOHANG)) > 0 ||
|
||||||
(pid < 0 && errno == EINTR))
|
(pid < 0 && errno == EINTR))
|
||||||
;
|
;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
errno = save_errno;
|
errno = save_errno;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user