all repos — tint2 @ 5521275befaa644c5f2150414aacf3d610fb892e

fork of the tint2 desktop panel for my custom setup - only minimized windows across all desktops for the taskbar

*fix* execute an external command by calling fork/execl and do not ignore SIGCHLD (maybe fixes issue 263)


git-svn-id: http://tint2.googlecode.com/svn/trunk@480 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
Andreas.Fink85 Andreas.Fink85@121b4492-b84c-0410-8b4c-0d4edfb3f3cc
commit

5521275befaa644c5f2150414aacf3d610fb892e

parent

e26cecf664b2bb8b445d389e8524c49c9d8a581d

5 files changed, 28 insertions(+), 18 deletions(-)

jump to
M src/battery/battery.csrc/battery/battery.c

@@ -39,6 +39,7 @@ #include "taskbar.h"

#include "battery.h" #include "clock.h" #include "timer.h" +#include "common.h" PangoFontDescription *bat1_font_desc; PangoFontDescription *bat2_font_desc;

@@ -352,8 +353,8 @@ if(energy_full > 0)

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;
M src/clock/clock.csrc/clock/clock.c

@@ -22,8 +22,6 @@ #include <stdio.h>

#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 "panel.h"

#include "taskbar.h" #include "clock.h" #include "timer.h" +#include "common.h" char *time1_format;

@@ -302,17 +301,6 @@ case 3:

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); }
M src/tint.csrc/tint.c

@@ -95,7 +95,7 @@ sigaction(SIGUSR1, &sa, 0);

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
M src/util/common.csrc/util/common.c

@@ -25,7 +25,7 @@ #include <X11/extensions/Xrender.h>

#include <stdio.h> #include <stdlib.h> #include <string.h> - +#include <unistd.h> #include "common.h" #include "../server.h"

@@ -74,6 +74,23 @@

g_strstrip(*key); g_strstrip(*value); return 1; +} + + +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); + } + } }
M src/util/common.hsrc/util/common.h

@@ -40,6 +40,10 @@

// 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);