Changes in uspace/lib/c/generic/task.c [0eff68e:7171760] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/task.c
r0eff68e r7171760 46 46 #include <libc.h> 47 47 #include "private/ns.h" 48 #include <vfs/vfs.h> 48 49 49 50 task_id_t task_get_id(void) … … 100 101 */ 101 102 int task_spawnv(task_id_t *id, const char *path, const char *const args[]) 103 { 104 /* Send default files */ 105 int *files[4]; 106 int fd_stdin; 107 int fd_stdout; 108 int fd_stderr; 109 110 if ((stdin != NULL) && (fhandle(stdin, &fd_stdin) == EOK)) 111 files[0] = &fd_stdin; 112 else 113 files[0] = NULL; 114 115 if ((stdout != NULL) && (fhandle(stdout, &fd_stdout) == EOK)) 116 files[1] = &fd_stdout; 117 else 118 files[1] = NULL; 119 120 if ((stderr != NULL) && (fhandle(stderr, &fd_stderr) == EOK)) 121 files[2] = &fd_stderr; 122 else 123 files[2] = NULL; 124 125 files[3] = NULL; 126 127 return task_spawnvf(id, path, args, files); 128 } 129 130 /** Create a new task by running an executable from the filesystem. 131 * 132 * This is really just a convenience wrapper over the more complicated 133 * loader API. Arguments are passed as a null-terminated array of strings. 134 * Files are passed as null-terminated array of pointers to fdi_node_t. 135 * 136 * @param id If not NULL, the ID of the task is stored here on success. 137 * @param path Pathname of the binary to execute. 138 * @param argv Command-line arguments. 139 * @param files Standard files to use. 140 * 141 * @return Zero on success or negative error code. 142 * 143 */ 144 int task_spawnvf(task_id_t *id, const char *path, const char *const args[], 145 int *const files[]) 102 146 { 103 147 /* Connect to a program loader. */ … … 127 171 goto error; 128 172 129 /* Send default files */ 130 fdi_node_t *files[4]; 131 fdi_node_t stdin_node; 132 fdi_node_t stdout_node; 133 fdi_node_t stderr_node; 134 135 if ((stdin != NULL) && (fnode(stdin, &stdin_node) == EOK)) 136 files[0] = &stdin_node; 137 else 138 files[0] = NULL; 139 140 if ((stdout != NULL) && (fnode(stdout, &stdout_node) == EOK)) 141 files[1] = &stdout_node; 142 else 143 files[1] = NULL; 144 145 if ((stderr != NULL) && (fnode(stderr, &stderr_node) == EOK)) 146 files[2] = &stderr_node; 147 else 148 files[2] = NULL; 149 150 files[3] = NULL; 151 173 /* Send files */ 152 174 rc = loader_set_files(ldr, files); 153 175 if (rc != EOK)
Note:
See TracChangeset
for help on using the changeset viewer.