gentoo-root / jackeventcmd Goto Github PK
View Code? Open in Web Editor NEWJack Event Handler
License: GNU General Public License v3.0
Jack Event Handler
License: GNU General Public License v3.0
You missed
signal(SIGCHLD, SIG_IGN);
from main.c when applying the fork patch.
jackeventcmd forks before launching commands and then calls system. This means that two processes are launched for each command; a jackeventcmd fork and sh -c. The process forked by jackeventcmd does not terminate properly. The following patch changes jackeventcmd to fork once and execute sh -c. The forked process exits correctly.
diff --git a/main.c b/main.c
index 99134aa..5a2ecab 100644
--- a/main.c
+++ b/main.c
@@ -19,6 +19,7 @@
#include "dbus.h"
#include <stdio.h>
#include <stdlib.h>
+#include <signal.h>
#include "run.h"
int main(int argc, char *argv[])
@@ -31,6 +32,7 @@ int main(int argc, char *argv[])
fprintf(stderr, "Unable to read config\n");
exit(16);
}
+ signal(SIGCHLD, SIG_IGN);
if (!je_dbus_init()) {
fprintf(stderr, "Unable to initialize D-Bus\n");
exit(1);
diff --git a/run.c b/run.c
index b3e813c..a2f0b6b 100644
--- a/run.c
+++ b/run.c
@@ -106,16 +106,12 @@ int read_config()
void run_cmds(int num)
{
- struct list_item_t *p;
- switch (fork()) {
- case -1:
- return;
- case 0:
- p = head[num];
- while (p) {
- printf("Running \"%s\"\n", p->command);
- if (system(p->command)) ;
- p = p->next;
+ struct list_item_t *p = head[num];
+ for (; p; p=p->next) {
+ printf("Running \"%s\"\n", p->command);
+ if (!fork()) {
+ execl("/bin/sh", "/bin/sh", "-c", p->command, NULL);
+ exit(1); /* in case of error */
}
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.