Improved buttonhandler

This commit is contained in:
Ashish Kumar Yadav 2020-10-03 16:02:07 +05:30
parent 30103c0c07
commit 365a047960

View file

@ -44,25 +44,24 @@ void
buttonhandler(int signal, siginfo_t *si, void *ucontext)
{
signal = si->si_value.sival_int >> 8;
for (Block *current = blocks; current->pathu; current++)
if (current->signal == signal)
switch (fork()) {
case -1:
perror("buttonhandler - fork");
exit(1);
break;
case 0:
close(ConnectionNumber(dpy));
for (Block *current = blocks; current->pathu; current++) {
if (current->signal == signal) {
{
char button[] = { '0' + (si->si_value.sival_int & 0xff), '\0' };
char *arg[] = { current->pathc, button, NULL };
close(ConnectionNumber(dpy));
setsid();
execv(arg[0], arg);
perror("buttonhandler - child - execv");
_exit(127);
}
}
exit(0);
}
}
void