int spawn_proxyattrs(FAR const posix_spawnattr_t *attr, FAR const posix_spawn_file_actions_t *file_actions) { FAR struct spawn_general_file_action_s *entry; int ret = OK; /* Check if we need to change the signal mask */ #ifndef CONFIG_DISABLE_SIGNALS if (attr && (attr->flags & POSIX_SPAWN_SETSIGMASK) != 0) { (void)sigprocmask(SIG_SETMASK, &attr->sigmask, NULL); } /* Were we also requested to perform file actions? */ if (file_actions) #endif { /* Yes.. Execute each file action */ for (entry = (FAR struct spawn_general_file_action_s *)file_actions; entry && ret == OK; entry = entry->flink) { switch (entry->action) { case SPAWN_FILE_ACTION_CLOSE: ret = spawn_close((FAR struct spawn_close_file_action_s *)entry); break; case SPAWN_FILE_ACTION_DUP2: ret = spawn_dup2((FAR struct spawn_dup2_file_action_s *)entry); break; case SPAWN_FILE_ACTION_OPEN: ret = spawn_open((FAR struct spawn_open_file_action_s *)entry); break; case SPAWN_FILE_ACTION_NONE: default: sdbg("ERROR: Unknown action: %d\n", entry->action); ret = EINVAL; break; } } } return ret; }
static int spawn_proxy(int argc, char *argv[]) { FAR struct spawn_general_file_action_s *entry; FAR const posix_spawnattr_t *attr = g_ps_parms.attr; int ret = OK; /* Perform file actions and/or set a custom signal mask. We get here only * if the file_actions parameter to posix_spawn[p] was non-NULL and/or the * option to change the signal mask was selected. */ #ifndef CONFIG_DISABLE_SIGNALS DEBUGASSERT((g_ps_parms.file_actions && *g_ps_parms.file_actions) || (attr && (attr->flags & POSIX_SPAWN_SETSIGMASK) != 0)); #else DEBUGASSERT(g_ps_parms.file_actions && *g_ps_parms.file_actions); #endif /* Check if we need to change the signal mask */ #ifndef CONFIG_DISABLE_SIGNALS if (attr && (attr->flags & POSIX_SPAWN_SETSIGMASK) != 0) { (void)sigprocmask(SIG_SETMASK, &attr->sigmask, NULL); } /* Were we also requested to perform file actions? */ if (g_ps_parms.file_actions) #endif { /* Execute each file action */ for (entry = (FAR struct spawn_general_file_action_s *)*g_ps_parms.file_actions; entry && ret == OK; entry = entry->flink) { switch (entry->action) { case SPAWN_FILE_ACTION_CLOSE: ret = spawn_close((FAR struct spawn_close_file_action_s *)entry); break; case SPAWN_FILE_ACTION_DUP2: ret = spawn_dup2((FAR struct spawn_dup2_file_action_s *)entry); break; case SPAWN_FILE_ACTION_OPEN: ret = spawn_open((FAR struct spawn_open_file_action_s *)entry); break; case SPAWN_FILE_ACTION_NONE: default: sdbg("ERROR: Unknown action: %d\n", entry->action); ret = EINVAL; break; } } } /* Check for failures */ if (ret == OK) { /* Start the task */ ret = spawn_exec(g_ps_parms.pid, g_ps_parms.path, attr, g_ps_parms.argv); #ifdef CONFIG_SCHED_HAVE_PARENT if (ret == OK) { /* Change of the parent of the task we just spawned to our parent. * What should we do in the event of a failure? */ int tmp = task_reparent(0, *g_ps_parms.pid); if (tmp < 0) { sdbg("ERROR: task_reparent() failed: %d\n", tmp); } } #endif } /* Post the semaphore to inform the parent task that we have completed * what we need to do. */ g_ps_parms.result = ret; #ifndef CONFIG_SCHED_WAITPID spawn_semgive(&g_ps_execsem); #endif return OK; }
void spawn_voxopen(widget *x) { spawn_open(NULL); }