/* * Screen_Suspend * */ static VALUE rb_ext_Screen_Suspend() { newtSuspend(); return Qnil; }
static void nmt_newt_suspend_callback (gpointer user_data) { newtSuspend (); kill (getpid (), SIGTSTP); newtResume (); }
static void nmt_newt_basic_g_log_handler (const char *log_domain, GLogLevelFlags log_level, const char *message, gpointer user_data) { newtSuspend (); g_log_default_handler (log_domain, log_level, message, NULL); newtResume (); }
/** * Exit Mondo normally. * @param signal The exit code (0 indicates a successful backup; 1 for Mondo means the * user aborted; 254 means a fatal error occured). * @note This function never returns. */ void finish(int signal) { char *command = NULL; /* if (signal==0) { popup_and_OK("Please press <enter> to quit."); } */ /* newtPopHelpLine(); */ register_pid(0, "mondo"); chdir("/"); run_program_and_log_output("umount " MNT_CDROM, FALSE); run_program_and_log_output("rm -Rf /mondo.scratch.* /mondo.tmp.*", FALSE); if (g_erase_tmpdir_and_scratchdir) { run_program_and_log_output(g_erase_tmpdir_and_scratchdir, 1); } if (g_selfmounted_isodir) { asprintf(&command, "umount %s", g_selfmounted_isodir); run_program_and_log_output(command, 1); asprintf(&command, "rmdir %s", g_selfmounted_isodir); run_program_and_log_output(command, 1); } // iamhere("foo"); /* system("clear"); */ // iamhere("About to call newtFinished"); if (!g_text_mode) { if (does_file_exist("/THIS-IS-A-RAMDISK")) { log_msg(1, "Calling newtFinished()"); newtFinished(); } else { log_msg(1, "Calling newtSuspend()"); newtSuspend(); } } // system("clear"); // iamhere("Finished calling newtFinished"); printf(_("Execution run ended; result=%d\n"), signal); printf(_("Type 'less %s' to see the output log\n"), MONDO_LOGFILE); free_libmondo_global_strings(); exit(signal); }
/** * nmt_newt_edit_string: * @data: data to edit * * libnewt does not have a multi-line editable text component, so * nmt-newt provides this function instead, which will open the user's * editor to edit a file containing the given @data (ensuring that the * current screen state is saved before starting the editor and * restored after it returns). * * Returns: the edited data, or %NULL if an error occurred. */ char * nmt_newt_edit_string (const char *data) { gssize len, nwrote; char *filename, *argv[3]; GError *error = NULL; int fd, status; char *new_data = NULL; fd = g_file_open_tmp ("XXXXXX.json", &filename, &error); if (fd == -1) { nmt_newt_message_dialog (_("Could not create temporary file: %s"), error->message); g_error_free (error); return NULL; } len = data ? strlen (data) : 0; while (len) { do nwrote = write (fd, data, len); while (nwrote == -1 && errno == EINTR); len -= nwrote; data += nwrote; } close (fd); argv[0] = (char *) g_getenv ("VISUAL"); if (!argv[0]) argv[0] = (char *) g_getenv ("EDITOR"); if (!argv[0]) argv[0] = (char *) "vi"; argv[1] = filename; argv[2] = NULL; newtSuspend (); g_spawn_sync (NULL, argv, NULL, G_SPAWN_SEARCH_PATH | G_SPAWN_CHILD_INHERITS_STDIN, NULL, NULL, NULL, NULL, &status, &error); newtResume (); if (error) { nmt_newt_message_dialog (_("Could not create temporary file: %s"), error->message); g_error_free (error); goto done; } #if GLIB_CHECK_VERSION (2, 34, 0) G_GNUC_BEGIN_IGNORE_DEPRECATIONS if (!g_spawn_check_exit_status (status, &error)) { nmt_newt_message_dialog (_("Editor failed: %s"), error->message); g_error_free (error); goto done; } G_GNUC_END_IGNORE_DEPRECATIONS #else if (WIFEXITED (status)) { if (WEXITSTATUS (status) != 0) nmt_newt_message_dialog (_("Editor failed with status %d"), WEXITSTATUS (status)); } else if (WIFSIGNALED (status)) nmt_newt_message_dialog (_("Editor failed with signal %d"), WTERMSIG (status)); #endif if (!g_file_get_contents (filename, &new_data, NULL, &error)) { nmt_newt_message_dialog (_("Could not re-read file: %s"), error->message); g_error_free (error); goto done; } done: unlink (filename); g_free (filename); return new_data; }
void suspend_to_console_newt(void) { newtSuspend(); }
/** * Call mkisofs to create an ISO image. * @param bkpinfo The backup information structure. Fields used: * - @c bkpinfo->manual_cd_tray * - @c bkpinfo->backup_media_type * - @c bkpinfo->please_dont_eject_when_restoring * @param basic_call The call to mkisofs. May contain tokens that will be resolved to actual data. The tokens are: * - @c _ISO_ will become the ISO file (@p isofile) * - @c _CD#_ becomes the CD number (@p cd_no) * - @c _ERR_ becomes the logfile (@p g_logfile) * @param isofile Replaces @c _ISO_ in @p basic_call. Should probably be the ISO image to create (-o parameter to mkisofs). * @param cd_no Replaces @c _CD#_ in @p basic_call. Should probably be the CD number. * @param logstub Unused. * @param what_i_am_doing The action taking place (e.g. "Making ISO #1"). Used as the title of the progress dialog. * @return Exit code of @c mkisofs (0 is success, anything else indicates failure). * @bug @p logstub is unused. */ int eval_call_to_make_ISO(struct s_bkpinfo *bkpinfo, char *basic_call, char *isofile, int cd_no, char *logstub, char *what_i_am_doing) { /*@ int's *** */ int retval = 0; /*@ buffers *** */ char *midway_call, *ultimate_call, *tmp, *command, *incoming, *old_stderr, *cd_number_str; char *p; /*@*********** End Variables ***************************************/ log_msg(3, "Starting"); assert(bkpinfo != NULL); assert_string_is_neither_NULL_nor_zerolength(basic_call); assert_string_is_neither_NULL_nor_zerolength(isofile); assert_string_is_neither_NULL_nor_zerolength(logstub); if (!(midway_call = malloc(1200))) { fatal_error("Cannot malloc midway_call"); } if (!(ultimate_call = malloc(1200))) { fatal_error("Cannot malloc ultimate_call"); } if (!(tmp = malloc(1200))) { fatal_error("Cannot malloc tmp"); } if (!(command = malloc(1200))) { fatal_error("Cannot malloc command"); } malloc_string(incoming); malloc_string(old_stderr); malloc_string(cd_number_str); incoming[0] = '\0'; old_stderr[0] = '\0'; sprintf(cd_number_str, "%d", cd_no); resolve_naff_tokens(midway_call, basic_call, isofile, "_ISO_"); resolve_naff_tokens(tmp, midway_call, cd_number_str, "_CD#_"); resolve_naff_tokens(ultimate_call, tmp, MONDO_LOGFILE, "_ERR_"); log_msg(4, "basic call = '%s'", basic_call); log_msg(4, "midway_call = '%s'", midway_call); log_msg(4, "tmp = '%s'", tmp); log_msg(4, "ultimate call = '%s'", ultimate_call); sprintf(command, "%s >> %s", ultimate_call, MONDO_LOGFILE); log_to_screen ("Please be patient. Do not be alarmed by on-screen inactivity."); log_msg(4, "Calling open_evalcall_form() with what_i_am_doing='%s'", what_i_am_doing); strcpy(tmp, command); if (bkpinfo->manual_cd_tray) { p = strstr(tmp, "2>>"); if (p) { sprintf(p, " "); while (*p == ' ') { p++; } for (; *p != ' '; p++) { *p = ' '; } } strcpy(command, tmp); #ifndef _XWIN if (!g_text_mode) { newtSuspend(); } #endif log_msg(1, "command = '%s'", command); retval += system(command); if (!g_text_mode) { newtResume(); } if (retval) { log_msg(2, "Basic call '%s' returned an error.", basic_call); popup_and_OK("Press ENTER to continue."); popup_and_OK ("mkisofs and/or cdrecord returned an error. CD was not created"); } } /* if text mode then do the above & RETURN; if not text mode, do this... */ else { log_msg(3, "command = '%s'", command); // yes_this_is_a_goto: retval = run_external_binary_with_percentage_indicator_NEW (what_i_am_doing, command); } paranoid_free(midway_call); paranoid_free(ultimate_call); paranoid_free(tmp); paranoid_free(command); paranoid_free(incoming); paranoid_free(old_stderr); paranoid_free(cd_number_str); /* if (bkpinfo->backup_media_type == dvd && !bkpinfo->please_dont_eject_when_restoring) { log_msg(3, "Ejecting DVD device"); eject_device(bkpinfo->media_device); } */ return (retval); }
void suspend(void * d) { newtSuspend(); raise(SIGTSTP); newtResume(); }