Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. /*
  2. FUNCTION
  3. <<system>>---execute command string
  4.  
  5. INDEX
  6.         system
  7. INDEX
  8.         _system_r
  9.  
  10. ANSI_SYNOPSIS
  11.         #include <stdlib.h>
  12.         int system(char *<[s]>);
  13.  
  14.         int _system_r(void *<[reent]>, char *<[s]>);
  15.  
  16. TRAD_SYNOPSIS
  17.         #include <stdlib.h>
  18.         int system(<[s]>)
  19.         char *<[s]>;
  20.  
  21.         int _system_r(<[reent]>, <[s]>)
  22.         char *<[reent]>;
  23.         char *<[s]>;
  24.  
  25. DESCRIPTION
  26.  
  27. Use <<system>> to pass a command string <<*<[s]>>> to <</bin/sh>> on
  28. your system, and wait for it to finish executing.
  29.  
  30. Use ``<<system(NULL)>>'' to test whether your system has <</bin/sh>>
  31. available.
  32.  
  33. The alternate function <<_system_r>> is a reentrant version.  The
  34. extra argument <[reent]> is a pointer to a reentrancy structure.
  35.  
  36. RETURNS
  37. <<system(NULL)>> returns a non-zero value if <</bin/sh>> is available, and
  38. <<0>> if it is not.
  39.  
  40. With a command argument, the result of <<system>> is the exit status
  41. returned by <</bin/sh>>.
  42.  
  43. PORTABILITY
  44. ANSI C requires <<system>>, but leaves the nature and effects of a
  45. command processor undefined.  ANSI C does, however, specify that
  46. <<system(NULL)>> return zero or nonzero to report on the existence of
  47. a command processor.
  48.  
  49. POSIX.2 requires <<system>>, and requires that it invoke a <<sh>>.
  50. Where <<sh>> is found is left unspecified.
  51.  
  52. Supporting OS subroutines required: <<_exit>>, <<_execve>>, <<_fork_r>>,
  53. <<_wait_r>>.
  54. */
  55.  
  56. #include <_ansi.h>
  57. #include <errno.h>
  58. #include <stddef.h>
  59. #include <stdlib.h>
  60. #include <unistd.h>
  61. #include <_syslist.h>
  62. #include <reent.h>
  63.  
  64.  
  65. int
  66. _DEFUN(_system_r, (ptr, s),
  67.      struct _reent *ptr _AND
  68.      _CONST char *s)
  69. {
  70.   if (s == NULL)
  71.     return 0;
  72.   errno = ENOSYS;
  73.   return -1;
  74. }
  75.  
  76. #ifndef _REENT_ONLY
  77.  
  78. int
  79. _DEFUN(system, (s),
  80.      _CONST char *s)
  81. {
  82.   return _system_r (_REENT, s);
  83. }
  84.  
  85. #endif
  86.