]> Dogcows Code - chaz/tint2/commitdiff
*fix* execute an external command by calling fork/execl and do not ignore SIGCHLD...
authorAndreas Fink <andreas.fink85@googlemail.com>
Fri, 11 Jun 2010 18:47:26 +0000 (18:47 +0000)
committerAndreas Fink <andreas.fink85@googlemail.com>
Fri, 11 Jun 2010 18:47:26 +0000 (18:47 +0000)
src/battery/battery.c
src/clock/clock.c
src/tint.c
src/util/common.c
src/util/common.h

index 5480412ada524ba8d173fe85ef463e1532ba520f..4bbde3cb2763fb6e3a1b529435e50eae85acd367 100644 (file)
@@ -39,6 +39,7 @@
 #include "battery.h"
 #include "clock.h"
 #include "timer.h"
+#include "common.h"
 
 PangoFontDescription *bat1_font_desc;
 PangoFontDescription *bat2_font_desc;
@@ -352,8 +353,8 @@ void update_battery() {
                new_percentage = (energy_now*100)/energy_full;
 
        if(battery_low_status > new_percentage && battery_state.state == BATTERY_DISCHARGING && !battery_low_cmd_send) {
-                       system(battery_low_cmd);  // return value == -1, since we've set SIGCHLD to SIGIGN
-                       battery_low_cmd_send = 1;
+               tint_exec(battery_low_cmd);
+               battery_low_cmd_send = 1;
        }
        if(battery_low_status < new_percentage && battery_state.state == BATTERY_CHARGING && battery_low_cmd_send) {
                battery_low_cmd_send = 0;
index 273fb818e17991089c391a52a85d1b9dc5ea9924..6e5032d24078e3d11932232841c2b834e6a618e3 100644 (file)
@@ -22,8 +22,6 @@
 #include <cairo.h>
 #include <cairo-xlib.h>
 #include <pango/pangocairo.h>
-#include <unistd.h>
-#include <signal.h>
 #include <stdlib.h>
 
 #include "window.h"
@@ -33,6 +31,7 @@
 #include "taskbar.h"
 #include "clock.h"
 #include "timer.h"
+#include "common.h"
 
 
 char *time1_format;
@@ -302,17 +301,6 @@ void clock_action(int button)
                command = clock_rclick_command;
                break;
        }
-       if (command) {
-               pid_t pid;
-               pid = fork();
-               if (pid == 0) {
-                       // change for the fork the signal mask
-//                     sigset_t sigset;
-//                     sigprocmask(SIG_SETMASK, &sigset, 0);
-//                     sigprocmask(SIG_UNBLOCK, &sigset, 0);
-                       execl("/bin/sh", "/bin/sh", "-c", command, NULL);
-                       _exit(0);
-               }
-       }
+  tint_exec(command);
 }
 
index 23394d9ef5a3f6f64ce35b10c7a9b8321d9b682b..fbe62ace07d5a19be7cd9f9666c81b469ab1a613 100644 (file)
@@ -95,7 +95,7 @@ void init (int argc, char *argv[])
        sigaction(SIGINT, &sa, 0);
        sigaction(SIGTERM, &sa, 0);
        sigaction(SIGHUP, &sa, 0);
-       signal(SIGCHLD, SIG_IGN);               // don't have to wait() after fork()
+//     signal(SIGCHLD, SIG_IGN);               // don't have to wait() after fork()
 
        // BSD is too stupid to support pselect(), therefore we have to use select and hope that we do not
        // end up in a race condition there
index 545a6be6e29689b723c9846f444dbc364c9afa61..629d29c52f1de297d1e6b039ea1904b2b399c4f5 100644 (file)
@@ -25,7 +25,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-
+#include <unistd.h>
 
 #include "common.h"
 #include "../server.h"
@@ -77,6 +77,23 @@ int parse_line (const char *line, char **key, char **value)
 }
 
 
+void tint_exec(const char *command)
+{
+       if (command) {
+               pid_t pid;
+               pid = fork();
+               if (pid == 0) {
+                       // change for the fork the signal mask
+//                     sigset_t sigset;
+//                     sigprocmask(SIG_SETMASK, &sigset, 0);
+//                     sigprocmask(SIG_UNBLOCK, &sigset, 0);
+                       execl("/bin/sh", "/bin/sh", "-c", command, NULL);
+                       _exit(0);
+               }
+       }
+}
+
+
 int hex_char_to_int (char c)
 {
        int r;
index e62051107c28aa29107dd3573678dd8530af6297..e85af7e099bd690970597d13326888cd571b5cd5 100644 (file)
@@ -40,6 +40,10 @@ void copy_file(const char *pathSrc, const char *pathDest);
 // extract key = value
 int parse_line (const char *line, char **key, char **value);
 
+// execute a command by calling fork
+void tint_exec(const char* command);
+
+
 // conversion
 int hex_char_to_int (char c);
 int hex_to_rgb (char *hex, int *r, int *g, int *b);
This page took 0.027201 seconds and 4 git commands to generate.