/** run_command(Command* cmd) ** Take a filled-out Command struct and run the command as specified. */ void run_command (Command* cmd) { //Fork cmd->pid = fork(); if(cmd->pid) { //Parent - add to background process list or wait if (cmd->background) { //Add to running background processes list add_background(cmd->pid); } else { wait_status(cmd->pid, 0); } } else { //Child //Input redirection (file or dev/null for background) if (cmd->background && !cmd->redirectIn) { dup2(open("/dev/null", O_RDONLY), 0); } else if (cmd->redirectIn) { dup2(fileno(cmd->redirectIn), STDIN_FILENO); fclose(cmd->redirectIn); } //Output redirection if (cmd->redirectOut) { dup2(fileno(cmd->redirectOut), STDOUT_FILENO); fclose(cmd->redirectOut); } //Reset normal signal handling signal(SIGINT, SIG_DFL); //Exec the child exec_child(cmd); } }
/* Create the iwb xml content file. */ static void create_xml_content (gchar *content_filename, gchar *img_dir_path, gchar *background_image) { int savepoint_number = -1; GDir *img_dir; fp = fopen (content_filename, "w"); add_header (); add_background (img_dir_path, background_image); if (!background_image) { savepoint_number = 0; } img_dir = g_dir_open (img_dir_path, 0, NULL); while (g_dir_read_name (img_dir)) { savepoint_number++; } g_dir_close (img_dir); add_savepoints (savepoint_number); add_background_reference (); add_savepoint_references (savepoint_number); close_iwb (); fclose (fp); }
int RmTest::init() { // set room properties /*set_width(3000); set_height(500); set_view(0, &vw_main); set_is_views_enabled(true);*/ // set backgrounds add_background(-1, bk_green, true, false, 0, 0, true, true, 10, 10, false); // set up instances add_instance(-1, obj_bee, 0, 0); return 0; }