prproces.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4. *
  5. * The contents of this file are subject to the Mozilla Public License Version
  6. * 1.1 (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. * http://www.mozilla.org/MPL/
  9. *
  10. * Software distributed under the License is distributed on an "AS IS" basis,
  11. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12. * for the specific language governing rights and limitations under the
  13. * License.
  14. *
  15. * The Original Code is the Netscape Portable Runtime (NSPR).
  16. *
  17. * The Initial Developer of the Original Code is
  18. * Netscape Communications Corporation.
  19. * Portions created by the Initial Developer are Copyright (C) 1998-2000
  20. * the Initial Developer. All Rights Reserved.
  21. *
  22. * Contributor(s):
  23. *
  24. * Alternatively, the contents of this file may be used under the terms of
  25. * either the GNU General Public License Version 2 or later (the "GPL"), or
  26. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27. * in which case the provisions of the GPL or the LGPL are applicable instead
  28. * of those above. If you wish to allow use of your version of this file only
  29. * under the terms of either the GPL or the LGPL, and not to allow others to
  30. * use your version of this file under the terms of the MPL, indicate your
  31. * decision by deleting the provisions above and replace them with the notice
  32. * and other provisions required by the GPL or the LGPL. If you do not delete
  33. * the provisions above, a recipient may use your version of this file under
  34. * the terms of any one of the MPL, the GPL or the LGPL.
  35. *
  36. * ***** END LICENSE BLOCK ***** */
  37. #ifndef prproces_h___
  38. #define prproces_h___
  39. #include "prtypes.h"
  40. #include "prio.h"
  41. PR_BEGIN_EXTERN_C
  42. /************************************************************************/
  43. /*****************************PROCESS OPERATIONS*************************/
  44. /************************************************************************/
  45. typedef struct PRProcess PRProcess;
  46. typedef struct PRProcessAttr PRProcessAttr;
  47. NSPR_API(PRProcessAttr *) PR_NewProcessAttr(void);
  48. NSPR_API(void) PR_ResetProcessAttr(PRProcessAttr *attr);
  49. NSPR_API(void) PR_DestroyProcessAttr(PRProcessAttr *attr);
  50. NSPR_API(void) PR_ProcessAttrSetStdioRedirect(
  51. PRProcessAttr *attr,
  52. PRSpecialFD stdioFd,
  53. PRFileDesc *redirectFd
  54. );
  55. /*
  56. * OBSOLETE -- use PR_ProcessAttrSetStdioRedirect instead.
  57. */
  58. NSPR_API(void) PR_SetStdioRedirect(
  59. PRProcessAttr *attr,
  60. PRSpecialFD stdioFd,
  61. PRFileDesc *redirectFd
  62. );
  63. NSPR_API(PRStatus) PR_ProcessAttrSetCurrentDirectory(
  64. PRProcessAttr *attr,
  65. const char *dir
  66. );
  67. NSPR_API(PRStatus) PR_ProcessAttrSetInheritableFD(
  68. PRProcessAttr *attr,
  69. PRFileDesc *fd,
  70. const char *name
  71. );
  72. /*
  73. ** Create a new process
  74. **
  75. ** Create a new process executing the file specified as 'path' and with
  76. ** the supplied arguments and environment.
  77. **
  78. ** This function may fail because of illegal access (permissions),
  79. ** invalid arguments or insufficient resources.
  80. **
  81. ** A process may be created such that the creator can later synchronize its
  82. ** termination using PR_WaitProcess().
  83. */
  84. NSPR_API(PRProcess*) PR_CreateProcess(
  85. const char *path,
  86. char *const *argv,
  87. char *const *envp,
  88. const PRProcessAttr *attr);
  89. NSPR_API(PRStatus) PR_CreateProcessDetached(
  90. const char *path,
  91. char *const *argv,
  92. char *const *envp,
  93. const PRProcessAttr *attr);
  94. NSPR_API(PRStatus) PR_DetachProcess(PRProcess *process);
  95. NSPR_API(PRStatus) PR_WaitProcess(PRProcess *process, PRInt32 *exitCode);
  96. NSPR_API(PRStatus) PR_KillProcess(PRProcess *process);
  97. PR_END_EXTERN_C
  98. #endif /* prproces_h___ */