2020-08-10 10:22:21 +02:00
|
|
|
/* dwm will keep pid's of processes from autostart array and kill them at quit */
|
|
|
|
static pid_t *autostart_pids;
|
|
|
|
static size_t autostart_len;
|
|
|
|
|
|
|
|
/* execute command from autostart array */
|
|
|
|
static void
|
|
|
|
autostart_exec()
|
|
|
|
{
|
|
|
|
const char *const *p;
|
2023-04-09 22:08:41 +02:00
|
|
|
struct sigaction sa;
|
2020-08-10 10:22:21 +02:00
|
|
|
size_t i = 0;
|
|
|
|
|
|
|
|
/* count entries */
|
|
|
|
for (p = autostart; *p; autostart_len++, p++)
|
|
|
|
while (*++p);
|
|
|
|
|
|
|
|
autostart_pids = malloc(autostart_len * sizeof(pid_t));
|
|
|
|
for (p = autostart; *p; i++, p++) {
|
|
|
|
if ((autostart_pids[i] = fork()) == 0) {
|
|
|
|
setsid();
|
2023-04-09 22:08:41 +02:00
|
|
|
|
|
|
|
/* Restore SIGCHLD sighandler to default before spawning a program */
|
|
|
|
sigemptyset(&sa.sa_mask);
|
|
|
|
sa.sa_flags = 0;
|
|
|
|
sa.sa_handler = SIG_DFL;
|
|
|
|
sigaction(SIGCHLD, &sa, NULL);
|
|
|
|
|
2020-08-10 10:22:21 +02:00
|
|
|
execvp(*p, (char *const *)p);
|
|
|
|
fprintf(stderr, "dwm: execvp %s\n", *p);
|
|
|
|
perror(" failed");
|
|
|
|
_exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
/* skip arguments */
|
|
|
|
while (*++p);
|
|
|
|
}
|
2021-06-14 07:16:17 +02:00
|
|
|
}
|
|
|
|
|