Changeset bb9ec2d in mainline for uspace/lib/c/generic/task.c


Ignore:
Timestamp:
2017-03-07T20:47:35Z (7 years ago)
Author:
Jakub Jermar <jakub@…>
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)
Message:

Merge from lp:~zarevucky-jiri/helenos/vfs-2.5/ revision 1941-1944

Original commit messages:

1944: Jiri Zarevucky 2013-08-06 Replace legacy file descriptor presetting with inbox.
1943: Jiri Zarevucky 2013-08-06 Do not preserve open state when passing file descriptor to another task. Allow receiver to specify, whether the descriptor is low or high.
1942: Jiri Zarevucky 2013-08-06 C style.
1941: Jiri Zarevucky 2013-08-06 Make loader accept file reference instead of a pathname.

Modifications:

  • Keep version of elf_load_file() that accepts file name
  • Changes required for loading dynamically linked executables
  • Update to newer list_foreach
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/task.c

    re796dc8 rbb9ec2d  
    107107{
    108108        /* 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);
    132128}
    133129
     
    138134 * Files are passed as null-terminated array of pointers to fdi_node_t.
    139135 *
    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.
    146143 *
    147144 * @return Zero on success or negative error code.
     
    149146 */
    150147int 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)
    152149{
    153150        /* Connect to a program loader. */
     
    169166                goto error;
    170167       
    171         /* Send program pathname. */
    172         rc = loader_set_pathname(ldr, path);
     168        /* Send program binary. */
     169        rc = loader_set_program_path(ldr, path);
    173170        if (rc != EOK)
    174171                goto error;
     
    180177       
    181178        /* 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        }               
    185196       
    186197        /* Load the program. */
Note: See TracChangeset for help on using the changeset viewer.