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 | |
6 | #ifndef prproces_h___ |
7 | #define prproces_h___ |
8 | |
9 | #include "prtypes.h" |
10 | #include "prio.h" |
11 | |
12 | PR_BEGIN_EXTERN_C |
13 | |
14 | /************************************************************************/ |
15 | /*****************************PROCESS OPERATIONS*************************/ |
16 | /************************************************************************/ |
17 | |
18 | typedef struct PRProcess PRProcess; |
19 | typedef struct PRProcessAttr PRProcessAttr; |
20 | |
21 | NSPR_API(PRProcessAttr *) PR_NewProcessAttr(void); |
22 | |
23 | NSPR_API(void) PR_ResetProcessAttr(PRProcessAttr *attr); |
24 | |
25 | NSPR_API(void) PR_DestroyProcessAttr(PRProcessAttr *attr); |
26 | |
27 | NSPR_API(void) PR_ProcessAttrSetStdioRedirect( |
28 | PRProcessAttr *attr, |
29 | PRSpecialFD stdioFd, |
30 | PRFileDesc *redirectFd |
31 | ); |
32 | |
33 | /* |
34 | * OBSOLETE -- use PR_ProcessAttrSetStdioRedirect instead. |
35 | */ |
36 | NSPR_API(void) PR_SetStdioRedirect( |
37 | PRProcessAttr *attr, |
38 | PRSpecialFD stdioFd, |
39 | PRFileDesc *redirectFd |
40 | ); |
41 | |
42 | NSPR_API(PRStatus) PR_ProcessAttrSetCurrentDirectory( |
43 | PRProcessAttr *attr, |
44 | const char *dir |
45 | ); |
46 | |
47 | NSPR_API(PRStatus) PR_ProcessAttrSetInheritableFD( |
48 | PRProcessAttr *attr, |
49 | PRFileDesc *fd, |
50 | const char *name |
51 | ); |
52 | |
53 | /* |
54 | ** Create a new process |
55 | ** |
56 | ** Create a new process executing the file specified as 'path' and with |
57 | ** the supplied arguments and environment. |
58 | ** |
59 | ** This function may fail because of illegal access (permissions), |
60 | ** invalid arguments or insufficient resources. |
61 | ** |
62 | ** A process may be created such that the creator can later synchronize its |
63 | ** termination using PR_WaitProcess(). |
64 | */ |
65 | |
66 | NSPR_API(PRProcess*) PR_CreateProcess( |
67 | const char *path, |
68 | char *const *argv, |
69 | char *const *envp, |
70 | const PRProcessAttr *attr); |
71 | |
72 | NSPR_API(PRStatus) PR_CreateProcessDetached( |
73 | const char *path, |
74 | char *const *argv, |
75 | char *const *envp, |
76 | const PRProcessAttr *attr); |
77 | |
78 | NSPR_API(PRStatus) PR_DetachProcess(PRProcess *process); |
79 | |
80 | NSPR_API(PRStatus) PR_WaitProcess(PRProcess *process, PRInt32 *exitCode); |
81 | |
82 | NSPR_API(PRStatus) PR_KillProcess(PRProcess *process); |
83 | |
84 | PR_END_EXTERN_C |
85 | |
86 | #endif /* prproces_h___ */ |
87 | |