static gboolean PowerOpsScriptCallback(GPid pid, gint exitStatus, gpointer _state) { PowerOpState *state = _state; gboolean success = exitStatus == 0; ASSERT(state->pid != INVALID_PID); if (WIFEXITED(exitStatus)) { g_message("Script exit code: %d, success = %d\n", WEXITSTATUS(exitStatus), success); } else if (WIFSIGNALED(exitStatus)) { g_message("Script killed by signal: %d, success = %d\n", WTERMSIG(exitStatus), success); } else if (WIFSTOPPED(exitStatus)) { g_message("Script stopped by signal: %d, success = %d\n", WSTOPSIG(exitStatus), success); } else { g_message("Script exit status: %d, success = %d\n", exitStatus, success); } PowerOpsStateChangeDone(_state, success); g_spawn_close_pid(state->pid); state->pid = INVALID_PID; return FALSE; }
void authorg_video_file_read_thumbnail (GPid pid, gint status, gpointer data) { AuthorgVideoFile *file = AUTHORG_VIDEO_FILE (data); if (WIFEXITED(status) && !WEXITSTATUS(status)) { /* success */ if (file->_priv->thumbnail) g_object_unref (file->_priv->thumbnail); file->_priv->thumbnail = gdk_pixbuf_new_from_file ( file->_priv->tmpthumb, NULL); g_object_ref (file->_priv->thumbnail); g_signal_emit (G_OBJECT (file), authorg_video_file_signals[GOT_ICON], 0, file->_priv->thumbnail); } close (file->_priv->tmpfd); g_unlink (file->_priv->tmpthumb); g_spawn_close_pid (pid); }
int main() { int retval = -1; #if defined(SYMBIAN) && (defined(__WINS__) || defined(__WINSCW__)) testResultXml("spawn_test"); return 0; #endif // EMULATOR #ifdef SYMBIAN g_log_set_handler (NULL, G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING | G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG, &mrtLogHandler, NULL); #endif // calling g_spawn_close_pid() with some invalid handle. Should not cause panic. // Instead the API should return without any problems. g_spawn_close_pid(146545); if(g_spawn_async_test() || g_spawn_async_with_pipes_test() || g_spawn_sync_test() || g_spawn_command_line_async_tests() || g_spawn_command_line_sync_tests()) retval = 1; else retval = 0; assert_failed = retval; #ifdef SYMBIAN testResultXml("spawn_test"); #endif /* EMULATOR */ return retval; }
/* read child output on child termination event */ static void netinfo_reap_child (GPid pid, gint status, gpointer user_data) { Netinfo *netinfo = (Netinfo *) user_data; gchar *primary = NULL; gchar *secondary = NULL; const gchar *page_label; gchar *cmd; g_spawn_close_pid (pid); g_return_if_fail (netinfo != NULL); g_return_if_fail (netinfo->command_line != NULL); page_label = gtk_label_get_text (GTK_LABEL (netinfo->page_label)); if (WEXITSTATUS(status) > 0) { cmd = g_strjoinv (" ", netinfo->command_line); primary = g_strdup_printf ( /* “%s” is the task name to run (e.g. Traceroute, Port Scan, Finger, etc.) */ _("An error occurred when try to run “%s”"), page_label); secondary = g_strdup_printf ("%s", cmd); netinfo_error_message (netinfo, primary, secondary); g_free (cmd); g_free (primary); g_free (secondary); } }
static void script_exited(GPid pid, int status, void *data) { struct capability_object *object = data; char buf[128]; object->pid = -1; DBG("pid: %d status: %d", pid, status); g_spawn_close_pid(pid); /* free the object if aborted */ if (object->aborted) { if (object->buffer != NULL) g_string_free(object->buffer, TRUE); g_free(object); return; } if (WEXITSTATUS(status) != EXIT_SUCCESS) { memset(buf, 0, sizeof(buf)); if (read(object->err, buf, sizeof(buf)) > 0) error("%s", buf); obex_object_set_io_flags(data, G_IO_ERR, -EPERM); } else obex_object_set_io_flags(data, G_IO_IN, 0); }
static void gs_subprocess_finalize (GObject *object) { GSSubprocess *self = GS_SUBPROCESS (object); if (self->pid_valid) { #ifdef G_OS_UNIX /* Here we need to actually call waitpid() to clean up the * zombie. In case the child hasn't actually exited, defer this * cleanup to the worker thread. */ if (!self->reaped_child) gs_subprocess_unix_queue_waitpid (self); #endif g_spawn_close_pid (self->pid); } g_clear_object (&self->stdin_pipe); g_clear_object (&self->stdout_pipe); g_clear_object (&self->stderr_pipe); if (G_OBJECT_CLASS (gs_subprocess_parent_class)->finalize != NULL) G_OBJECT_CLASS (gs_subprocess_parent_class)->finalize (object); }
/* * called on GDB exit */ static void on_gdb_exit(GPid pid, gint status, gpointer data) { gdb_pid = target_pid = 0; g_spawn_close_pid(pid); shutdown_channel(&gdb_ch_in); shutdown_channel(&gdb_ch_out); /* delete autos */ g_list_foreach(autos, (GFunc)g_free, NULL); g_list_free(autos); autos = NULL; /* delete watches */ g_list_foreach(watches, (GFunc)g_free, NULL); g_list_free(watches); watches = NULL; /* delete files */ g_list_foreach(files, (GFunc)g_free, NULL); g_list_free(files); files = NULL; g_source_destroy(gdb_src); dbg_cbs->set_exited(0); }
static void cleanup_func (GPid pid, gint status G_GNUC_UNUSED, gpointer user_data G_GNUC_UNUSED) { g_spawn_close_pid (pid); }
/* Clean up passwd resources */ static void free_passwd_resources (PasswordDialog *pdialog) { GError *error = NULL; /* Remove the child watcher */ if (pdialog->backend_child_watch_id != 0) { g_source_remove (pdialog->backend_child_watch_id); pdialog->backend_child_watch_id = 0; } /* Close IO channels (internal file descriptors are automatically closed) */ if (pdialog->backend_stdin != NULL) { if (g_io_channel_shutdown (pdialog->backend_stdin, TRUE, &error) != G_IO_STATUS_NORMAL) { g_warning (_("Could not shutdown backend_stdin IO channel: %s"), error->message); g_error_free (error); error = NULL; } g_io_channel_unref (pdialog->backend_stdin); pdialog->backend_stdin = NULL; } if (pdialog->backend_stdout != NULL) { if (g_io_channel_shutdown (pdialog->backend_stdout, TRUE, &error) != G_IO_STATUS_NORMAL) { g_warning (_("Could not shutdown backend_stdout IO channel: %s"), error->message); g_error_free (error); error = NULL; } g_io_channel_unref (pdialog->backend_stdout); pdialog->backend_stdout = NULL; } /* Remove IO watcher */ if (pdialog->backend_stdout_watch_id != 0) { g_source_remove (pdialog->backend_stdout_watch_id); pdialog->backend_stdout_watch_id = 0; } /* Close PID */ if (pdialog->backend_pid != -1) { g_spawn_close_pid (pdialog->backend_pid); pdialog->backend_pid = -1; } /* Clear backend state */ pdialog->backend_state = PASSWD_STATE_NONE; }
void capture_opts_del_iface(capture_options *capture_opts, guint if_index) { interface_options interface_opts; interface_opts = g_array_index(capture_opts->ifaces, interface_options, if_index); /* XXX - check if found? */ g_free(interface_opts.name); g_free(interface_opts.descr); if (interface_opts.console_display_name != NULL) g_free(interface_opts.console_display_name); g_free(interface_opts.cfilter); #ifdef HAVE_EXTCAP g_free(interface_opts.extcap); g_free(interface_opts.extcap_fifo); if (interface_opts.extcap_args) g_hash_table_unref(interface_opts.extcap_args); if (interface_opts.extcap_pid > 0) g_spawn_close_pid(interface_opts.extcap_pid); #endif #ifdef HAVE_PCAP_REMOTE if (interface_opts.src_type == CAPTURE_IFREMOTE) { g_free(interface_opts.remote_host); g_free(interface_opts.remote_port); g_free(interface_opts.auth_username); g_free(interface_opts.auth_password); } #endif capture_opts->ifaces = g_array_remove_index(capture_opts->ifaces, if_index); }
static void unoconv_child_watch_cb (GPid pid, gint status, gpointer user_data) { PdfLoadJob *job = user_data; if (job->cancellable != NULL) { g_cancellable_disconnect (job->cancellable, job->cancelled_id); job->cancelled_id = 0; } g_spawn_close_pid (pid); job->unoconv_pid = -1; /* We need to clean up the downloaded file (if any) that was * converted. */ if (job->download_file != NULL) { g_file_delete (job->download_file, NULL, NULL); g_clear_object (&job->download_file); } if (g_cancellable_is_cancelled (job->cancellable)) { pdf_load_job_complete_error (job, g_error_new_literal (G_IO_ERROR, G_IO_ERROR_CANCELLED, "Operation cancelled")); return; } pdf_load_job_cache_set_attributes (job); }
/****************************************************************************** * Name * on_quit_activate * * Synopsis * #include "gui/main_menu.h" * * void on_quit_activate(GtkMenuItem * menuitem, gpointer user_data) * * Description * do a nice orderly shut down and exit xiphos * by calling gtk_widget_destroy() which will call * on_mainwindow_destroy() * * Return value * void */ G_MODULE_EXPORT void on_quit_activate(GtkMenuItem *menuitem, gpointer user_data) { /* discover main window internal geometry before we go. */ final_pane_sizes(); #if defined(WIN32) && defined(HAVE_DBUS) /* we started dbus-daemon ourselves, so we must kill it, too. */ extern GPid dbus_pid; g_spawn_close_pid(dbus_pid); #endif /* offer to save all editors remaining open */ editor_maybe_save_all(); shutdown_frontend(); /* shutdown the sword stuff */ main_shutdown_backend(); gtk_main_quit(); #if 0 /* this causes trouble when paratab is active. and frankly, why do we care? we're about to exit. just leave. */ gtk_widget_destroy(widgets.app); #endif exit(0); }
bool Process::wait(int &res) { #ifdef _WIN32 input_.close(); DWORD status; if (WaitForSingleObject((HANDLE)pid_, INFINITE) != WAIT_OBJECT_0 || !GetExitCodeProcess((HANDLE)pid_, &status)) { g_warning(_("Can not get status of spawned process\n")); return false; } res = status; g_spawn_close_pid(pid_); #else input_.close(); int status; if (waitpid(pid_, &status, 0) == -1) { g_critical("Can get status of process: %s\n", strerror(errno)); return false; } res = WEXITSTATUS(status); #endif return true; }
static void fixture_tear_down(TestFixture *fixture, gconstpointer data) { gchar *tmp; kill(fixture->pid, SIGTERM); g_main_loop_run(fixture->loop); g_main_loop_unref(fixture->loop); g_spawn_close_pid(fixture->pid); tmp = g_build_filename(fixture->test_dir, "foo", NULL); g_unlink(tmp); g_free(tmp); tmp = g_build_filename(fixture->test_dir, "qga.state", NULL); g_unlink(tmp); g_free(tmp); tmp = g_build_filename(fixture->test_dir, "sock", NULL); g_unlink(tmp); g_free(tmp); g_rmdir(fixture->test_dir); g_free(fixture->test_dir); }
///pdftk_pid_watch wird aufgerufen sobald der pdftk-Prozess beendet ist void pdftk_child_watch_func (GPid pdftk_pid,gint status,gpointer user_data){ GError *error = NULL; //Status abfragen g_spawn_check_exit_status (status,&error); if (error!=NULL){ g_warning("%s",error->message); g_error_free(error); error = NULL; } //Pid schließen (ist unter UNIX nicht nötig) g_spawn_close_pid(pdftk_pid); //fertiges PDF direkt anzeigen GString *folderpath=NULL; folderpath = g_string_new ("file://"); folderpath = g_string_append (folderpath,keyfile_get_outputdir()); folderpath = g_string_append (folderpath,"/"); folderpath = g_string_append (folderpath,keyfile_get_pdf_name()); g_print("pdf_anzeigen:\t%s\n",folderpath->str); gtk_show_uri (NULL,folderpath->str,GDK_CURRENT_TIME,&error); if (error!=NULL){ g_warning("%s",error->message); g_error_free(error); error = NULL; } g_string_free(folderpath,TRUE); interface_ausgrauen(TRUE); temp_dir_delete(); }
static void teardown (Fixture *f, gconstpointer context G_GNUC_UNUSED) { dbus_error_free (&f->e); g_clear_error (&f->ge); if (f->left_conn != NULL) { dbus_connection_close (f->left_conn); dbus_connection_unref (f->left_conn); f->left_conn = NULL; } if (f->right_conn != NULL) { if (f->right_conn_echo) { dbus_connection_remove_filter (f->right_conn, echo_filter, NULL); f->right_conn_echo = FALSE; } dbus_connection_close (f->right_conn); dbus_connection_unref (f->right_conn); f->right_conn = NULL; } #ifdef DBUS_WIN TerminateProcess (f->daemon_pid, 1); #else kill (f->daemon_pid, SIGTERM); #endif g_spawn_close_pid (f->daemon_pid); }
static void fetch_gravatar_done(GPid pid, gint status, gpointer data) { user_priv *c G_GNUC_UNUSED = data; plugin_instance *p G_GNUC_UNUSED = data; gchar *image = NULL, *icon = NULL; ENTER; DBG("status %d\n", status); g_spawn_close_pid(c->pid); c->pid = 0; c->sid = 0; if (status) RET(); DBG("rebuild menu\n"); XCG(p->xc, "icon", &icon, strdup); XCG(p->xc, "image", &image, strdup); XCS(p->xc, "image", image, value); xconf_del(xconf_find(p->xc, "icon", 0), FALSE); PLUGIN_CLASS(k)->destructor(p); PLUGIN_CLASS(k)->constructor(p); if (image) { XCS(p->xc, "image", image, value); g_free(image); } if (icon) { XCS(p->xc, "icon", icon, value); g_free(icon); } RET(); }
static void child_watch_handler (GPid pid, gint status, BlockData *data) { g_debug ("child exited"); if (! WIFEXITED (status)) { if (data->error) { /* override possible errors */ g_error_free (data->error); } if (WIFSIGNALED (status)) { data->error = g_error_new (G_SPAWN_ERROR, G_SPAWN_ERROR_FAILED, "Child received signal %d (%s)", WTERMSIG (status), data->error_str->str); } else { data->error = g_error_new (G_SPAWN_ERROR, G_SPAWN_ERROR_FAILED, "Child crashed (%s)", data->error_str->str); } } else if (WEXITSTATUS (status) != 0) { if (data->error) { /* override possible errors */ g_error_free (data->error); } data->error = g_error_new (G_SPAWN_ERROR, G_SPAWN_ERROR_FAILED, "Child returned with error code %d (%s)", WEXITSTATUS (status), data->error_str->str); } else { g_debug ("child succeeded"); } g_spawn_close_pid (pid); g_main_loop_quit (data->loop); }
static void editor_child_exit_cb(GPid pid, gint status, gpointer data) { EditorData *ed = data; g_spawn_close_pid(pid); ed->pid = -1; editor_command_next_finish(ed, status); }
void pg_util_stop_qemu(int qemu_pid) { int exit_status; kill(qemu_pid, SIGKILL); waitpid(qemu_pid, &exit_status, 0); g_spawn_close_pid(qemu_pid); }
static void gw_kanjipadwindow_finalize (GObject *object) { GwKanjipadWindow *window; GwKanjipadWindowPrivate *priv; GSource *source; GError *error; GList *link; window = GW_KANJIPADWINDOW (object); priv = window->priv; error = NULL; for (link = priv->strokes; link != NULL; link = link->next) gw_kanjipadwindow_free_drawingarea_stroke (link->data); if (priv->strokes != NULL) g_list_free (priv->strokes); priv->strokes = NULL; if (priv->strokes != NULL) g_list_free (priv->curstroke); priv->curstroke = NULL; if (priv->ksurface != NULL) cairo_surface_destroy (priv->ksurface); priv->ksurface = NULL; if (priv->surface != NULL) cairo_surface_destroy (priv->surface); priv->surface = NULL; if (g_main_current_source () != NULL && !g_source_is_destroyed (g_main_current_source ()) && priv->iowatchid > 0 ) { source = g_main_context_find_source_by_id (NULL, priv->iowatchid); if (source != NULL) { g_source_destroy (source); } } priv->iowatchid = 0; if (error == NULL) { g_io_channel_shutdown (priv->from_engine, FALSE, &error); g_io_channel_unref (priv->from_engine); priv->from_engine = NULL; } if (error == NULL) { g_io_channel_shutdown (priv->to_engine, FALSE, &error); g_io_channel_unref (priv->to_engine); priv->to_engine = NULL; } g_spawn_close_pid (priv->engine_pid); if (error != NULL) { fprintf(stderr, "Errored: %s\n", error->message); exit(EXIT_FAILURE); } G_OBJECT_CLASS (gw_kanjipadwindow_parent_class)->finalize (object); }
void seahorse_tool_progress_stop () { if (progress_pid != -1) { kill (progress_pid, SIGTERM); g_spawn_close_pid (progress_pid); progress_pid = -1; } }
static void on_child_exit( GPid child_pid, gint status, gpointer data) { char *infile = (char *) data; char *destdir = NULL; g_message("pid %lu exited with status %d", (gulong) child_pid, status); #ifdef G_OS_UNIX if (WIFEXITED(status)) { if (WEXITSTATUS(status) == EXIT_SUCCESS) { g_debug("pid %lu returned success", (gulong) child_pid); if (g_ascii_strcasecmp(fd_nextdir, "delete")) destdir = fd_nextdir; } else { g_warning("pid %lu returned error status %d", (gulong) child_pid, WEXITSTATUS(status)); if (g_ascii_strcasecmp(fd_faildir, "delete")) destdir = fd_faildir; } } else if (WIFSIGNALED(status)) { g_critical("pid %lu terminated with signal %d\n", (gulong) child_pid, WTERMSIG(status)); if (g_ascii_strcasecmp(fd_faildir, "delete")) destdir = fd_faildir; } else { g_critical("pid %lu terminated", (gulong) child_pid); } #endif /* G_OS_UNIX */ /* Do move or delete */ if (destdir) { if (*destdir) { GString *destpath = g_string_new(""); char *dbase = NULL; /* Calculate move destination path */ dbase = g_path_get_basename(infile); g_string_printf(destpath, "%s/%s", destdir, dbase); if (dbase) free(dbase); /* Do link */ g_message("moving %s -> %s", infile, destpath->str); if (link(infile, destpath->str) < 0) g_critical( "error moving input file to destination directory: %s", strerror(errno)); g_string_free(destpath, TRUE); } } /* Do delete */ if (unlink(infile) < 0) g_critical("error deleting input file"); g_spawn_close_pid(child_pid); }
static void script_exited(GPid pid, gint status, gpointer data) { if (WIFEXITED(status)) debug("%d exited with status %d", pid, WEXITSTATUS(status)); else debug("%d was killed by signal %d", pid, WTERMSIG(status)); g_spawn_close_pid(pid); }
static void stopTestServer() { // Do nothing if there's no server running. if (!gChildProcessPid) return; g_spawn_close_pid(gChildProcessPid); kill(gChildProcessPid, SIGTERM); gChildProcessPid = 0; }
static void deja_dup_async_command_handle_done (DejaDupAsyncCommand* self, GPid pid, gint sig) { gint _tmp0_; GPid _tmp1_; g_return_if_fail (self != NULL); _tmp0_ = sig; g_signal_emit_by_name (self, "done", _tmp0_ == 0); _tmp1_ = pid; g_spawn_close_pid (_tmp1_); self->priv->pid = (GPid) 0; }
void remmina_nx_session_free (RemminaNXSession *nx) { pthread_t thread; if (nx->proxy_watch_source) { g_source_remove (nx->proxy_watch_source); nx->proxy_watch_source = 0; } if (nx->proxy_pid) { kill (nx->proxy_pid, SIGTERM); g_spawn_close_pid (nx->proxy_pid); nx->proxy_pid = 0; } thread = nx->thread; if (thread) { nx->running = FALSE; pthread_cancel (thread); pthread_join (thread, NULL); nx->thread = 0; } if (nx->channel) { channel_close (nx->channel); channel_free (nx->channel); } if (nx->server_sock >= 0) { close (nx->server_sock); nx->server_sock = -1; } g_free (nx->server); g_free (nx->error); g_hash_table_destroy (nx->session_parameters); g_string_free (nx->response, TRUE); g_free (nx->version); g_free (nx->session_id); g_free (nx->proxy_cookie); if (nx->session_list) { g_object_unref (nx->session_list); nx->session_list = NULL; } if (nx->session) { ssh_free (nx->session); nx->session = NULL; } g_free (nx); }
///unoconv_pid_watch wird aufgerufen sobald der unoconv-Prozess beendet ist void unoconv_child_watch_func (GPid unoconv_pid,gint status,gpointer user_data){ GError *error = NULL; //Status abfragen g_spawn_check_exit_status (status,&error); if (error!=NULL){ g_warning("%s",error->message); g_error_free(error); error = NULL; } //Pid schließen (ist unter UNIX nicht nötig) g_spawn_close_pid(unoconv_pid); //pdftk aufruf bauen GPtrArray *pdftk_argv= g_ptr_array_new (); //Funktion zum aufräumen setzten g_ptr_array_set_free_func(pdftk_argv,ptr_array_clean); GPid pdftk_pid=0; fill_g_ptr_array (pdftk_argv,"pdftk"); //den ListStore durchlaufen lassen, und pfad bauen gtk_tree_model_foreach(gtk_tree_view_get_model(gui_get_gtk_tree_viewer()),treemodel_ausgabe_pdftk,(gpointer)pdftk_argv); fill_g_ptr_array (pdftk_argv,"output"); //speichert den Pfad g_ptr_array_add(pdftk_argv,(gpointer)keyfile_get_pdf_full_path()); g_ptr_array_add(pdftk_argv,(gpointer)NULL); //PDF zusammenfügen g_spawn_async_with_pipes (NULL, (gchar**)pdftk_argv->pdata, NULL, G_SPAWN_SEARCH_PATH|G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, &pdftk_pid, NULL, NULL, NULL, &error); if (error!=NULL){ g_warning("%s",error->message); g_error_free(error); error = NULL; } //g_child_watch einrichten, um über Programmende(pdftk) informiert zu werden g_child_watch_add(pdftk_pid,pdftk_child_watch_func,NULL); //aufräumen g_ptr_array_free(pdftk_argv,TRUE); //g_print("das PDF \"%s\" wurde unter \"%s\" erstellt\n",keyfile_get_pdf_name(),keyfile_get_outputdir()); //Buttons wieder aktivieren interface_ausgrauen(TRUE); }
static void kill_child_now (void) { if (g_child_watch_id) g_source_remove (g_child_watch_id); if (g_child_pid) { g_spawn_close_pid (g_child_pid); kill (g_child_pid, SIGTERM); } }
static void async_task_callback(GPid pid, gint status, __unused__ gpointer null) { LOG("PID %d ends, exit status %d\n", pid, status); g_spawn_close_pid(pid); --tasks; if (0 == tasks) { LOG(MOD "Quit main loop\n"); g_main_loop_quit(main_loop); } }