prproces.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef prproces_h___
  6. #define prproces_h___
  7. #include "prtypes.h"
  8. #include "prio.h"
  9. PR_BEGIN_EXTERN_C
  10. /************************************************************************/
  11. /*****************************PROCESS OPERATIONS*************************/
  12. /************************************************************************/
  13. typedef struct PRProcess PRProcess;
  14. typedef struct PRProcessAttr PRProcessAttr;
  15. NSPR_API(PRProcessAttr *) PR_NewProcessAttr(void);
  16. NSPR_API(void) PR_ResetProcessAttr(PRProcessAttr *attr);
  17. NSPR_API(void) PR_DestroyProcessAttr(PRProcessAttr *attr);
  18. NSPR_API(void) PR_ProcessAttrSetStdioRedirect(
  19. PRProcessAttr *attr,
  20. PRSpecialFD stdioFd,
  21. PRFileDesc *redirectFd
  22. );
  23. /*
  24. * OBSOLETE -- use PR_ProcessAttrSetStdioRedirect instead.
  25. */
  26. NSPR_API(void) PR_SetStdioRedirect(
  27. PRProcessAttr *attr,
  28. PRSpecialFD stdioFd,
  29. PRFileDesc *redirectFd
  30. );
  31. NSPR_API(PRStatus) PR_ProcessAttrSetCurrentDirectory(
  32. PRProcessAttr *attr,
  33. const char *dir
  34. );
  35. NSPR_API(PRStatus) PR_ProcessAttrSetInheritableFD(
  36. PRProcessAttr *attr,
  37. PRFileDesc *fd,
  38. const char *name
  39. );
  40. /*
  41. ** Create a new process
  42. **
  43. ** Create a new process executing the file specified as 'path' and with
  44. ** the supplied arguments and environment.
  45. **
  46. ** This function may fail because of illegal access (permissions),
  47. ** invalid arguments or insufficient resources.
  48. **
  49. ** A process may be created such that the creator can later synchronize its
  50. ** termination using PR_WaitProcess().
  51. */
  52. NSPR_API(PRProcess*) PR_CreateProcess(
  53. const char *path,
  54. char *const *argv,
  55. char *const *envp,
  56. const PRProcessAttr *attr);
  57. NSPR_API(PRStatus) PR_CreateProcessDetached(
  58. const char *path,
  59. char *const *argv,
  60. char *const *envp,
  61. const PRProcessAttr *attr);
  62. NSPR_API(PRStatus) PR_DetachProcess(PRProcess *process);
  63. NSPR_API(PRStatus) PR_WaitProcess(PRProcess *process, PRInt32 *exitCode);
  64. NSPR_API(PRStatus) PR_KillProcess(PRProcess *process);
  65. PR_END_EXTERN_C
  66. #endif /* prproces_h___ */