Changeset eb1edb0 in mainline
- Timestamp:
- 2011-07-26T22:16:54Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1e591c8
- Parents:
- d542aad
- Location:
- uspace/lib/posix/sys
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/posix/sys/wait.c
rd542aad reb1edb0 39 39 #include "wait.h" 40 40 41 #include "../libc/task.h" 42 #include "../assert.h" 43 #include "../errno.h" 44 #include "../limits.h" 45 #include "../signal.h" 46 47 int __posix_wifexited(int status) { 48 return status != INT_MIN; 49 } 50 51 int __posix_wexitstatus(int status) { 52 assert(__posix_wifexited(status)); 53 return status; 54 } 55 56 int __posix_wifsignaled(int status) { 57 return status == INT_MIN; 58 } 59 60 int __posix_wtermsig(int status) { 61 assert(__posix_wifsignaled(status)); 62 /* There is no way to distinguish reason 63 * for unexpected termination at the moment. 64 */ 65 return SIGABRT; 66 } 67 41 68 /** 42 69 * … … 46 73 posix_pid_t posix_wait(int *stat_ptr) 47 74 { 48 // TODO: low priority, just a compile-time dependency of binutils 49 not_implemented(); 75 /* HelenOS does not support this. */ 76 errno = ENOSYS; 77 return (posix_pid_t) -1; 50 78 } 51 79 … … 59 87 posix_pid_t posix_waitpid(posix_pid_t pid, int *stat_ptr, int options) 60 88 { 61 // TODO: low priority, just a compile-time dependency of binutils 62 not_implemented(); 89 assert(stat_ptr != NULL); 90 assert(options == 0 /* None of the options are supported. */); 91 92 task_exit_t texit; 93 int retval; 94 95 int rc = task_wait((task_id_t) pid, &texit, &retval); 96 97 if (rc < 0) { 98 /* Unable to retrieve status. */ 99 errno = -rc; 100 return (posix_pid_t) -1; 101 } 102 103 if (texit == TASK_EXIT_NORMAL) { 104 // FIXME: relies on application not returning this value 105 assert(retval != INT_MIN); 106 *stat_ptr = retval; 107 } else { 108 /* Reserve the lowest value for unexpected termination. */ 109 *stat_ptr = INT_MIN; 110 } 111 112 return pid; 63 113 } 64 114 -
uspace/lib/posix/sys/wait.h
rd542aad reb1edb0 38 38 #include "types.h" 39 39 40 #undef WIFEXITED 41 #undef WEXITSTATUS 42 #undef WIFSIGNALED 43 #undef WTERMSIG 44 #define WIFEXITED(status) __posix_wifexited(status) 45 #define WEXITSTATUS(status) __posix_wexitstatus(status) 46 #define WIFSIGNALED(status) __posix_wifsignaled(status) 47 #define WTERMSIG(status) __posix_wtermsig(status) 48 49 extern int __posix_wifexited(int status); 50 extern int __posix_wexitstatus(int status); 51 extern int __posix_wifsignaled(int status); 52 extern int __posix_wtermsig(int status); 53 40 54 extern posix_pid_t posix_wait(int *stat_ptr); 41 55 extern posix_pid_t posix_waitpid(posix_pid_t pid, int *stat_ptr, int options); … … 43 57 #ifndef LIBPOSIX_INTERNAL 44 58 #define wait posix_wait 45 #define waitpid 59 #define waitpid posix_waitpid 46 60 #endif 47 61
Note:
See TracChangeset
for help on using the changeset viewer.