diff --git a/Documentation/NuttxUserGuide.html b/Documentation/NuttxUserGuide.html index 89bc08942a..c6eabd29a5 100644 --- a/Documentation/NuttxUserGuide.html +++ b/Documentation/NuttxUserGuide.html @@ -13,7 +13,7 @@

NuttX Operating System

User's Manual

by

Gregory Nutt

-

Last Updated: January 8, 2013

+

Last Updated: January 11, 2013

@@ -193,18 +193,52 @@ paragraphs.

Task Control Interfaces. The following task control interfaces are provided by NuttX:

+

+ Non-standard task control interfaces inspired by VxWorks interfaces: +

+

+ Standard interfaces +

+ +

+ Standard vfork and exec[v|l] interfaces: +

+ +

+ Standard posix_spawn interfaces: +

+ +

2.1.1 task_create

@@ -472,53 +506,7 @@ STATUS taskDelete(int tid);
  • Deletion of self is supported, but only because task_delete() will re-direct processing to exit(). -

    2.1.5 exit

    - -

    -Function Prototype: -

    -    #include <sched.h>
    -    void exit(int code);
    -
    -    #include <nuttx/unistd.h>
    -    void _exit(int code);
    -
    - -

    -Description: This function causes the calling task to cease -to exist -- its stack and TCB will be deallocated. exit differs from -_exit in that it flushes streams, closes file descriptors and will -execute any function registered with atexit() or on_exit(). -

    -Input Parameters: -

    - -

    -Returned Value: None. - -

    -Assumptions/Limitations: - -

    -POSIX Compatibility: This is equivalent to the ANSI interface: -

    -    void exit(int code);
    -
    -And the UNIX interface: -
    -    void _exit(int code);
    -
    - -

    - The NuttX exit() differs from ANSI exit() in the following ways: -

    - - -

    2.1.6 task_restart

    +

    2.1.5 task_restart

    Function Prototype:

    +

    2.1.6 exit

    + +

    +Function Prototype: +

    +    #include <sched.h>
    +    void exit(int code);
    +
    +    #include <nuttx/unistd.h>
    +    void _exit(int code);
    +
    + +

    +Description: This function causes the calling task to cease +to exist -- its stack and TCB will be deallocated. exit differs from +_exit in that it flushes streams, closes file descriptors and will +execute any function registered with atexit() or on_exit(). +

    +Input Parameters: +

    + +

    +Returned Value: None. + +

    +Assumptions/Limitations: + +

    +POSIX Compatibility: This is equivalent to the ANSI interface: +

    +    void exit(int code);
    +
    +And the UNIX interface: +
    +    void _exit(int code);
    +
    + +

    + The NuttX exit() differs from ANSI exit() in the following ways: +

    + +

    2.1.7 getpid

    @@ -780,6 +814,595 @@ int execl(FAR const char *path, ...); There are, however, several compatibility issues as detailed in the description of execv().

    +

    2.1.11 posix_spawn and posix_spawnp

    +

    + Function Prototype: +

    + +

    + Description: + The posix_spawn() and posix_spawnp() functions will create a new, child task, constructed from a regular executable file.

    +

    +

    + Input Parameters: +

    + +

    + Returned Value: + posix_spawn() and posix_spawnp() will return zero on success. + Otherwise, an error number will be returned as the function return value to indicate the error: +

    + +

    + Assumptions/Limitations: +

    + +

    + POSIX Compatibility: + The value of the argv[0] received by the child task is assigned by NuttX. + For the caller of posix_spawn(), the provided argv[0] will correspond to argv[1] received by the new task. +

    + +

    2.1.12 posix_spawn_file_actions_init

    +

    + Function Prototype: +

    + +

    + Description: + The posix_spawn_file_actions_init() function initializes the object referenced by file_actions to an empty set of file actions for subsequent use in a call to posix_spawn() or posix_spawnp(). +

    +

    + Input Parameters: +

    + +

    + Returned Value: + On success, this function returns 0; on failure it will return an error number from <errno.h>. +

    + +

    2.1.13 posix_spawn_file_actions_destroy

    +

    + Function Prototype: +

    + +

    + Description: + The posix_spawn_file_actions_destroy() function destroys the object referenced by file_actions which was previously intialized by posix_spawn_file_actions_init(), returning any resources obtained at the time of initialization to the system for subsequent reuse. + A posix_spawn_file_actions_t may be reinitialized after having been destroyed, but must not be reused after destruction, unless it has been reinitialized. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + On success, this function returns 0; on failure it will return an error number from <errno.h> +

    + +

    2.1.14 posix_spawn_file_actions_addclose

    +

    + Function Prototype: +

    + +

    + Description: + The posix_spawn_file_actions_addclose() function adds a close operation to the list of operations associated with the object referenced by file_actions, for subsequent use in a call to posix_spawn() or posix_spawnp(). + The descriptor referred to by fd is closed as if close() had been called on it prior to the new child process starting execution. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + On success, this function returns 0; on failure it will return an error number from <errno.h> +

    + +

    2.1.15 posix_spawn_file_actions_adddup2

    +

    + Function Prototype: +

    + +

    + Description: + The posix_spawn_file_actions_adddup2() function adds a dup2 operation to the list of operations associated with the object referenced by file_actions, for subsequent use in a call to posix_spawn() or posix_spawnp(). + The descriptor referred to by fd2 is created as if dup2() had been called on fd1 prior to the new child process starting execution. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + On success, this function returns 0; on failure it will return an error number from <errno.h> +

    + +

    2.1.16 posix_spawn_file_actions_addopen

    +

    + Function Prototype: +

    + +

    + Description: + The posix_spawn_file_actions_addopen() function adds an open operation to the list of operations associated with the object referenced by file_actions, for subsequent use in a call to posix_spawn() or posix_spawnp(). + The descriptor referred to by fd is opened using the path, oflag, and mode arguments as if open() had been called on it prior to the new child process starting execution. + The string path is copied by the posix_spawn_file_actions_addopen() function during this process, so storage need not be persistent in the caller. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + On success, this function returns 0; on failure it will return an error number from <errno.h> +

    + +

    2.1.17 posix_spawnattr_init

    +

    + Function Prototype: +

    + +

    + Description: + The posix_spawnattr_init() function initializes the object referenced by attr, to an empty set of spawn attributes for subsequent use in a call to posix_spawn() or posix_spawnp(). +

    +

    + Then the spawn attributes are no longer needed, they should be destroyed by calling posix_spawnattr_destroyed(). + In NuttX, however, posix_spawnattr_destroyed() is just stub: +

    + +

    + For portability, the convention of calling posix_spawnattr_destroyed() when the attributes are not longer needed should still be followed. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + On success, this function returns 0; on failure it will return an error number from <errno.h> +

    + +

    2.1.18 posix_spawnattr_getflags

    +

    + Function Prototype: +

    + +

    + Description: + The posix_spawnattr_getflags() function will obtain the value of the spawn-flags attribute from the attributes object referenced by attr. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + On success, this function returns 0; on failure it will return an error number from <errno.h> +

    + +

    2.1.19 posix_spawnattr_getschedparam

    +

    + Function Prototype: +

    + +

    + Description: + The posix_spawnattr_getschedparam() function will obtain the value of the spawn-schedparam attribute from the attributes object referenced by attr. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + On success, this function returns 0; on failure it will return an error number from <errno.h> +

    + +

    2.1.20 posix_spawnattr_getschedpolicy

    +

    + Function Prototype: +

    + +

    + Description: + The posix_spawnattr_getschedpolicy() function will obtain the value of the spawn-schedpolicy attribute from the attributes object referenced by attr. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + On success, this function returns 0; on failure it will return an error number from <errno.h> +

    + +

    2.1.21 posix_spawnattr_getsigmask

    +

    + Function Prototype: +

    + +

    + Description: + The posix_spawnattr_getsigdefault() function will obtain the value of the spawn-sigmask attribute from the attributes object referenced by attr. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + On success, this function returns 0; on failure it will return an error number from <errno.h> +

    + +

    2.1.22 posix_spawnattr_setflags

    +

    + Function Prototype: +

    + +

    + Description: + The posix_spawnattr_setflags() function will set the spawn-flags attribute in an initialized attributes object referenced by attr. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + On success, this function returns 0; on failure it will return an error number from <errno.h> +

    + +

    2.1.23 posix_spawnattr_setschedparam

    +

    + Function Prototype: +

    + +

    + Description: + The posix_spawnattr_setschedparam() function will set the spawn-schedparam attribute in an initialized attributes object referenced by attr. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + On success, this function returns 0; on failure it will return an error number from <errno.h> +

    + +

    2.1.24 posix_spawnattr_setschedpolicy

    +

    + Function Prototype: +

    + +

    + Description: + The posix_spawnattr_setschedpolicy() function will set the spawn-schedpolicy attribute in an initialized attributes object referenced by attr. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + On success, this function returns 0; on failure it will return an error number from <errno.h> +

    + +

    2.1.25 posix_spawnattr_setsigmask

    +

    + Function Prototype: +

    + +

    + Description: + The posix_spawnattr_setsigmask() function will set the spawn-sigmask attribute in an initialized attributes object referenced by attr. +

    +

    + Input Parameters: +

    + +

    + Returned Value: + On success, this function returns 0; on failure it will return an error number from <errno.h> +

    + - + + -
    @@ -8395,13 +9018,30 @@ notify a task when a message is available on a queue.
  • on_exit
  • open
  • opendir
  • -
  • OS Interfaces
  • pause
  • pipe
  • poll
  • poll.h
  • +
    +
  • posix_spawn
  • +
  • posix_spawn_file_actions_addclose
  • +
  • posix_spawn_file_actions_adddup2
  • +
  • posix_spawn_file_actions_addopen
  • +
  • posix_spawn_file_actions_destroy
  • +
  • posix_spawn_file_actions_init
  • +
  • posix_spawnattr_init
  • +
  • posix_spawnattr_destroy
  • +
  • posix_spawnattr_getflags
  • +
  • posix_spawnattr_getschedparam
  • +
  • posix_spawnattr_getschedpolicy
  • +
  • posix_spawnattr_getsigmask
  • +
  • posix_spawnattr_setflags
  • +
  • posix_spawnattr_setschedparam
  • +
  • posix_spawnattr_setschedpolicy
  • +
  • posix_spawnattr_setsigmask
  • +
  • posix_spawnp
  • printf
  • Pthread Interfaces
  • pthread_attr_destroy
  • @@ -8467,6 +9107,8 @@ notify a task when a message is available on a queue.
  • recv
  • recvfrom
  • rename
  • +
  • rmdir
  • rewinddir
  • ROM disk driver
  • @@ -8474,8 +9116,6 @@ notify a task when a message is available on a queue.
  • sched_getparam
  • sched_get_priority_max
  • sched_get_priority_min
  • -
  • sched_get_rr_interval
  • sched_lockcount
  • sched_lock
  • diff --git a/TODO b/TODO index e257cef79f..92b7ab4f57 100644 --- a/TODO +++ b/TODO @@ -866,7 +866,17 @@ o File system / Generic drivers (fs/, drivers/) Title: dup AND dup2 WILL NOT WORK ON FILES IN A MOUNTED VOLUME Description: The current implementation of dup() and dup2() will only work with open device drivers and sockets. It will not - work with open files in a file system. + work with open files in a file system. Support for dup'ing + open files on a mounted volume has not been implemented yet. + + There is a stubbed out, partial implemenation in fs/fs_files.c. + In would perform the dup2() operation by re-opening the file + and setting the file pointer. The logic, however, would require + that we remember the (relative) path to the file in the mounted + volume for each open file. + + An option might to add a dup() method to the file system + mountpoint interface. A limitation that results from this is that you cannot redirect I/O to an from and file. diff --git a/include/spawn.h b/include/spawn.h index 39ed9be15c..5e0ce3416c 100644 --- a/include/spawn.h +++ b/include/spawn.h @@ -112,7 +112,7 @@ extern "C" #ifdef CONFIG_BINFMT_EXEPATH int posix_spawnp(FAR pid_t *pid, FAR const char *path, FAR const posix_spawn_file_actions_t *file_actions, - FAR const posix_spawnattr_t * attr, + FAR const posix_spawnattr_t *attr, FAR char *const argv[], FAR char *const envp[]); #define posix_spawn(pid,path,file_actions,attr,argv,envp) \ posix_spawnp(pid,path,file_actions,attr,argv,envp) diff --git a/libc/spawn/lib_ps.c b/libc/spawn/lib_ps.c index a6a0590d4a..dfe57089e2 100644 --- a/libc/spawn/lib_ps.c +++ b/libc/spawn/lib_ps.c @@ -440,7 +440,7 @@ static int spawn_proxy(int argc, char *argv[]) * * Description: * The posix_spawn() and posix_spawnp() functions will create a new, - * child task, constructed a regular executable file. + * child task, constructed from a regular executable file. * * Input Parameters: * @@ -479,9 +479,9 @@ static int spawn_proxy(int argc, char *argv[]) * not supported. NuttX does not support process groups. * - POSIX_SPAWN_SETSCHEDPARAM: Set new tasks priority to the sched_param * value. - * - POSIX_SPAWN_SETSCHEDULER: Set the new task's scheduler priority to + * - POSIX_SPAWN_SETSCHEDULER: Set the new task's scheduler policy to * the sched_policy value. - * - POSIX_SPAWN_RESETIDS: Resetting of effective user ID of the child + * - POSIX_SPAWN_RESETIDS: Resetting of the effective user ID of the child * process is not supported. NuttX does not support effective user * IDs. * - POSIX_SPAWN_SETSIGMASK: Set the new task's signal mask. @@ -514,11 +514,12 @@ static int spawn_proxy(int argc, char *argv[]) * CONFIG_BINFMT_EXEPATH is defined, then only posix_spawnp() behavior * is supported; otherwise, only posix_spawn behavior is supported. * - The 'envp' argument is not used and the 'environ' variable is not - * altered (NuttX does not support the 'environ' variable. + * altered (NuttX does not support the 'environ' variable). * - Process groups are not supported (POSIX_SPAWN_SETPGROUP). * - Effective user IDs are not supported (POSIX_SPAWN_RESETIDS). - * - Signal masks and signal default actions cannot be modified in the - * newly executed task (POSIX_SPAWN_SETSIGDEF and POSIX_SPAWN_SETSIGMASK). + * - Signal default actions cannot be modified in the newly task executed + * because NuttX does not support default signal actions + * (POSIX_SPAWN_SETSIGDEF). * * POSIX Compatibility * - The value of the argv[0] received by the child task is assigned by diff --git a/libc/spawn/lib_psa_getschedparam.c b/libc/spawn/lib_psa_getschedparam.c index 65cec47f14..ed8cb1f700 100644 --- a/libc/spawn/lib_psa_getschedparam.c +++ b/libc/spawn/lib_psa_getschedparam.c @@ -57,7 +57,7 @@ * * Input Parameters: * attr - The address spawn attributes to be queried. - * flags - The location to return the sched_priority value. + * flags - The location to return the spawn-schedparam value. * * Returned Value: * On success, these functions return 0; on failure they return an error diff --git a/libc/spawn/lib_psa_getsigmask.c b/libc/spawn/lib_psa_getsigmask.c index 3c831075ee..dd3495b4d0 100644 --- a/libc/spawn/lib_psa_getsigmask.c +++ b/libc/spawn/lib_psa_getsigmask.c @@ -59,7 +59,7 @@ * * Input Parameters: * attr - The address spawn attributes to be queried. - * sigmask - The location to return the spawn flags + * sigmask - The location to return the signal mask * * Returned Value: * On success, these functions return 0; on failure they return an error diff --git a/libc/spawn/lib_psa_setschedparam.c b/libc/spawn/lib_psa_setschedparam.c index 8d3356aafd..5e992e8a92 100644 --- a/libc/spawn/lib_psa_setschedparam.c +++ b/libc/spawn/lib_psa_setschedparam.c @@ -56,8 +56,8 @@ * by attr. * * Input Parameters: - * attr - The address spawn attributes to be used. - * parm - The new sched_priority to set. + * attr - The address spawn attributes to be used. + * param - The new sched_priority to set. * * Returned Value: * On success, these functions return 0; on failure they return an error diff --git a/libc/spawn/lib_psfa_addopen.c b/libc/spawn/lib_psfa_addopen.c index bcb2012913..385e1cfc33 100644 --- a/libc/spawn/lib_psfa_addopen.c +++ b/libc/spawn/lib_psfa_addopen.c @@ -57,8 +57,8 @@ * Description: * The posix_spawn_file_actions_addopen() function adds an open operation * to the list of operations associated with the object referenced by - * file_actions, for subsequent use in a call to posix_spawn(2) or - * posix_spawnp(2). The descriptor referred to by fd is opened using + * file_actions, for subsequent use in a call to posix_spawn() or + * posix_spawnp(). The descriptor referred to by fd is opened using * the path, oflag, and mode arguments as if open() had been called on it * prior to the new child process starting execution. The string path is * copied by the posix_spawn_file_actions_addopen() function during this @@ -66,8 +66,8 @@ * * Input Parameters: * file_actions - The posix_spawn_file_actions_t to append the action. - * fd - The path to be opened. - * path - The first file descriptor to be argument to dup2. + * fd - The file descriptor to be opened. + * path - The path to be opened. * oflags - Open flags * mode - File creation mode * diff --git a/libc/spawn/lib_psfa_init.c b/libc/spawn/lib_psfa_init.c index 4e23703aec..5c902125a8 100644 --- a/libc/spawn/lib_psfa_init.c +++ b/libc/spawn/lib_psfa_init.c @@ -50,7 +50,7 @@ * * Description: * The posix_spawn_file_actions_init() function initializes the object - * referenced by file_actions, to an empty set of file actions for + * referenced by file_actions to an empty set of file actions for * subsequent use in a call to posix_spawn() or posix_spawnp(). * * Input Parameters: