static void apply_changes_on_x(const char *current, const String *previous) { if(repeat_press_value) XAutoRepeatOn(fl_display); else XAutoRepeatOff(fl_display); /* do not do anything if selected layout is the same as previous */ if(!previous || *previous != current) { /* * believe me, it is easier to call this command than to reimplmement a mess for * uploading keyboard layout on X server! */ String setxkbmap = file_path("setxkbmap"); if(setxkbmap.empty()) { alert(_("Unable to find 'setxkbmap' tool.\n\nThis tool is used as helper tool for " "easier keyboard setup and is standard tool shipped with every X package. " "Please install it first and run this program again.")); } else { int ret = run_sync("%s %s", setxkbmap.c_str(), current); /* do not show dialog since we can fail if config has bad entry when called from apply_chages_from_config() */ if(ret != 0) E_WARNING(E_STRLOC ": 'setxkbmap %s' failed with %i\n", current, ret); } } /* force panel applet to re-read config file to see if flag should be displayed or not */ foreign_callback_call(PANEL_APPLET_ID); }
static int run_async(struct mad_decoder *decoder) { pid_t pid; int ptoc[2], ctop[2], flags; if (pipe(ptoc) == -1) return -1; if (pipe(ctop) == -1) { close(ptoc[0]); close(ptoc[1]); return -1; } flags = fcntl(ptoc[0], F_GETFL); if (flags == -1 || fcntl(ptoc[0], F_SETFL, flags | O_NONBLOCK) == -1) { close(ctop[0]); close(ctop[1]); close(ptoc[0]); close(ptoc[1]); return -1; } pid = fork(); if (pid == -1) { close(ctop[0]); close(ctop[1]); close(ptoc[0]); close(ptoc[1]); return -1; } decoder->async.pid = pid; if (pid) { /* parent */ close(ptoc[0]); close(ctop[1]); decoder->async.in = ctop[0]; decoder->async.out = ptoc[1]; return 0; } /* child */ close(ptoc[1]); close(ctop[0]); decoder->async.in = ptoc[0]; decoder->async.out = ctop[1]; _exit(run_sync(decoder)); /* not reached */ return -1; }
void run() const { if (!cb && !async_cb) { // stubbed return; } if (async) run_async(); else run_sync(); }
static void start_crasher(const char* cmd, int sig) { const char* base = get_basename(cmd); const char* ede_app_flag = ""; /* this means the app was called without full path */ if(!base) base = cmd; /* * determine is our app by checking the prefix; we don't want user to send bug reports about crashes * of foreign applications */ if(strncmp(base, "ede-", 4) == 0) ede_app_flag = "--edeapp"; /* call edelib implementation instead start_child_process() to prevents loops if 'ede-crasher' crashes */ run_sync("ede-crasher %s --appname %s --apppath %s --signal %i", ede_app_flag, base, cmd, sig); }
static gboolean run_commands (GitgShell *shell, GitgCommand **commands, GError **error) { GitgIO *io; GitgRunner *prev = NULL; GOutputStream *output; gboolean ret = TRUE; GitgCommand **ptr; io = GITG_IO (shell); output = gitg_io_get_output (io); shell->priv->read_done = TRUE; gitg_io_cancel (GITG_IO (shell)); gitg_io_begin (GITG_IO (shell)); /* Ref sink all commands */ for (ptr = commands; *ptr; ++ptr) { g_object_ref_sink (*ptr); } if (shell->priv->synchronized) { shell->priv->main_loop = g_main_loop_new (NULL, FALSE); } /* Setup runners */ for (ptr = commands; *ptr; ++ptr) { GitgRunner *runner; runner = gitg_runner_new (*ptr); if (gitg_io_get_stderr_to_stdout (GITG_IO (shell))) { gitg_io_set_stderr_to_stdout (GITG_IO (runner), TRUE); } g_signal_connect (runner, "end", G_CALLBACK (runner_end), shell); if (ptr == commands) { /* Copy input set on the shell to the first runner */ GInputStream *input; input = gitg_io_get_input (io); if (input != NULL) { gitg_io_set_input (GITG_IO (runner), input); } } else { /* Set output of the previous runner to the input of this runner */ gitg_io_set_input (GITG_IO (runner), gitg_runner_get_stream (prev)); } if (!*(ptr + 1)) { shell->priv->last_runner = runner; /* Copy output set on the shell to the last runner */ if (output != NULL) { gitg_io_set_output (GITG_IO (runner), output); } } shell->priv->runners = g_slist_append (shell->priv->runners, runner); /* Start the runner */ gitg_runner_run (runner); if (shell->priv->runners == NULL) { /* This means it there was an error */ if (error && shell->priv->error) { *error = g_error_copy (shell->priv->error); } if (shell->priv->error) { g_error_free (shell->priv->error); shell->priv->error = NULL; } ret = FALSE; goto cleanup; } prev = runner; } /* Setup line reader if necessary in async mode */ if (output == NULL) { run_stream (shell, gitg_runner_get_stream (shell->priv->last_runner)); } if (shell->priv->synchronized) { return run_sync (shell, error); } cleanup: for (ptr = commands; *ptr; ++ptr) { g_object_unref (*ptr); } if (shell->priv->main_loop) { g_main_loop_unref (shell->priv->main_loop); shell->priv->main_loop = NULL; } return ret; }