mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-27 20:44:56 +00:00
Only ever fork() once.
This commit is contained in:
parent
0ae9108874
commit
000acfe0fd
12
src/conky.c
12
src/conky.c
@ -353,6 +353,10 @@ static unsigned long total_run_times;
|
||||
/* fork? */
|
||||
static int fork_to_background;
|
||||
|
||||
/* set to 0 after the first time conky is run, so we don't fork again after the
|
||||
* first forking */
|
||||
static int first_pass = 1;
|
||||
|
||||
static int cpu_avg_samples, net_avg_samples, diskio_avg_samples;
|
||||
|
||||
/* filenames for output */
|
||||
@ -5615,7 +5619,7 @@ void initialisation(int argc, char **argv) {
|
||||
|
||||
while (1) {
|
||||
int c = getopt_long(argc, argv, getopt_string, longopts, NULL);
|
||||
static int startup_pause = 0;
|
||||
int startup_pause;
|
||||
|
||||
if (c == -1) {
|
||||
break;
|
||||
@ -5678,7 +5682,7 @@ void initialisation(int argc, char **argv) {
|
||||
break;
|
||||
#endif /* X11 */
|
||||
case 'p':
|
||||
if (startup_pause == 0) {
|
||||
if (first_pass) {
|
||||
startup_pause = atoi(optarg);
|
||||
sleep(startup_pause);
|
||||
}
|
||||
@ -5704,7 +5708,7 @@ void initialisation(int argc, char **argv) {
|
||||
}
|
||||
global_text = NULL;
|
||||
/* fork */
|
||||
if (fork_to_background) {
|
||||
if (fork_to_background && first_pass) {
|
||||
int pid = fork();
|
||||
|
||||
switch (pid) {
|
||||
@ -5912,6 +5916,8 @@ int main(int argc, char **argv)
|
||||
|
||||
initialisation(argc, argv);
|
||||
|
||||
first_pass = 0; /* don't ever call fork() again */
|
||||
|
||||
main_loop();
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
|
Loading…
Reference in New Issue
Block a user