Changeset 368ee04 in mainline for uspace/lib/c/generic/task.c
- Timestamp:
- 2017-04-05T18:10:39Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 93ad8166
- Parents:
- 39f892a9 (diff), 2166728 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/task.c
r39f892a9 r368ee04 48 48 #include "private/ns.h" 49 49 #include <vfs/vfs.h> 50 #include <unistd.h> 50 51 51 52 task_id_t task_get_id(void) … … 107 108 { 108 109 /* Send default files */ 109 int *files[4]; 110 int fd_stdin; 111 int fd_stdout; 112 int fd_stderr; 113 114 if ((stdin != NULL) && (vfs_fhandle(stdin, &fd_stdin) == EOK)) 115 files[0] = &fd_stdin; 116 else 117 files[0] = NULL; 118 119 if ((stdout != NULL) && (vfs_fhandle(stdout, &fd_stdout) == EOK)) 120 files[1] = &fd_stdout; 121 else 122 files[1] = NULL; 123 124 if ((stderr != NULL) && (vfs_fhandle(stderr, &fd_stderr) == EOK)) 125 files[2] = &fd_stderr; 126 else 127 files[2] = NULL; 128 129 files[3] = NULL; 130 131 return task_spawnvf(id, wait, path, args, files); 110 111 int fd_stdin = -1; 112 int fd_stdout = -1; 113 int fd_stderr = -1; 114 115 if (stdin != NULL) { 116 (void) vfs_fhandle(stdin, &fd_stdin); 117 } 118 119 if (stdout != NULL) { 120 (void) vfs_fhandle(stdout, &fd_stdout); 121 } 122 123 if (stderr != NULL) { 124 (void) vfs_fhandle(stderr, &fd_stderr); 125 } 126 127 return task_spawnvf(id, wait, path, args, fd_stdin, fd_stdout, 128 fd_stderr); 132 129 } 133 130 … … 138 135 * Files are passed as null-terminated array of pointers to fdi_node_t. 139 136 * 140 * @param id If not NULL, the ID of the task is stored here on success. 141 * @param wait If not NULL, setup waiting for task's return value and store 142 * the information necessary for waiting here on success. 143 * @param path Pathname of the binary to execute. 144 * @param argv Command-line arguments. 145 * @param files Standard files to use. 137 * @param id If not NULL, the ID of the task is stored here on success. 138 * @param wait If not NULL, setup waiting for task's return value and store 139 * @param path Pathname of the binary to execute. 140 * @param argv Command-line arguments. 141 * @param std_in File to use as stdin. 142 * @param std_out File to use as stdout. 143 * @param std_err File to use as stderr. 146 144 * 147 145 * @return Zero on success or negative error code. … … 149 147 */ 150 148 int task_spawnvf(task_id_t *id, task_wait_t *wait, const char *path, 151 const char *const args[], int *const files[])149 const char *const args[], int fd_stdin, int fd_stdout, int fd_stderr) 152 150 { 153 151 /* Connect to a program loader. */ … … 169 167 goto error; 170 168 171 /* Send program pathname. */172 rc = loader_set_p athname(ldr, path);169 /* Send program binary. */ 170 rc = loader_set_program_path(ldr, path); 173 171 if (rc != EOK) 174 172 goto error; … … 180 178 181 179 /* Send files */ 182 rc = loader_set_files(ldr, files); 183 if (rc != EOK) 184 goto error; 180 int root = vfs_root(); 181 if (root >= 0) { 182 rc = loader_add_inbox(ldr, "root", root); 183 vfs_put(root); 184 if (rc != EOK) 185 goto error; 186 } 187 188 if (fd_stdin >= 0) { 189 rc = loader_add_inbox(ldr, "stdin", fd_stdin); 190 if (rc != EOK) 191 goto error; 192 } 193 194 if (fd_stdout >= 0) { 195 rc = loader_add_inbox(ldr, "stdout", fd_stdout); 196 if (rc != EOK) 197 goto error; 198 } 199 200 if (fd_stderr >= 0) { 201 rc = loader_add_inbox(ldr, "stderr", fd_stderr); 202 if (rc != EOK) 203 goto error; 204 } 185 205 186 206 /* Load the program. */
Note:
See TracChangeset
for help on using the changeset viewer.