Changeset bb9ec2d in mainline for uspace/lib/c/generic/task.c
- Timestamp:
- 2017-03-07T20:47:35Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a737667e
- Parents:
- e796dc8
- git-author:
- Jiri Zarevucky <zarevucky.jiri@…> (2017-03-07 20:47:35)
- git-committer:
- Jakub Jermar <jakub@…> (2017-03-07 20:47:35)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/task.c
re796dc8 rbb9ec2d 107 107 { 108 108 /* 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); 109 110 int fd_stdin = -1; 111 int fd_stdout = -1; 112 int fd_stderr = -1; 113 114 if (stdin != NULL) { 115 (void) vfs_fhandle(stdin, &fd_stdin); 116 } 117 118 if (stdout != NULL) { 119 (void) vfs_fhandle(stdout, &fd_stdout); 120 } 121 122 if (stderr != NULL) { 123 (void) vfs_fhandle(stderr, &fd_stderr); 124 } 125 126 return task_spawnvf(id, wait, path, args, fd_stdin, fd_stdout, 127 fd_stderr); 132 128 } 133 129 … … 138 134 * Files are passed as null-terminated array of pointers to fdi_node_t. 139 135 * 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. 136 * @param id If not NULL, the ID of the task is stored here on success. 137 * @param wait If not NULL, setup waiting for task's return value and store 138 * @param path Pathname of the binary to execute. 139 * @param argv Command-line arguments. 140 * @param std_in File to use as stdin. 141 * @param std_out File to use as stdout. 142 * @param std_err File to use as stderr. 146 143 * 147 144 * @return Zero on success or negative error code. … … 149 146 */ 150 147 int task_spawnvf(task_id_t *id, task_wait_t *wait, const char *path, 151 const char *const args[], int *const files[])148 const char *const args[], int fd_stdin, int fd_stdout, int fd_stderr) 152 149 { 153 150 /* Connect to a program loader. */ … … 169 166 goto error; 170 167 171 /* Send program pathname. */172 rc = loader_set_p athname(ldr, path);168 /* Send program binary. */ 169 rc = loader_set_program_path(ldr, path); 173 170 if (rc != EOK) 174 171 goto error; … … 180 177 181 178 /* Send files */ 182 rc = loader_set_files(ldr, files); 183 if (rc != EOK) 184 goto error; 179 if (fd_stdin >= 0) { 180 rc = loader_add_inbox(ldr, "stdin", fd_stdin); 181 if (rc != EOK) 182 goto error; 183 } 184 185 if (fd_stdout >= 0) { 186 rc = loader_add_inbox(ldr, "stdout", fd_stdout); 187 if (rc != EOK) 188 goto error; 189 } 190 191 if (fd_stderr >= 0) { 192 rc = loader_add_inbox(ldr, "stderr", fd_stderr); 193 if (rc != EOK) 194 goto error; 195 } 185 196 186 197 /* Load the program. */
Note:
See TracChangeset
for help on using the changeset viewer.