1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
|
// -*- C++ -*-
//
// $Id$
#include "ace/ACE.h"
#include "ace/OS_NS_sys_wait.h"
#include "ace/OS_NS_signal.h"
#include "ace/OS_NS_pwd.h"
#include "ace/OS_NS_string.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE void
ACE_Process_Options::enable_unicode_environment (void)
{
this->use_unicode_environment_ = true;
}
ACE_INLINE void
ACE_Process_Options::disable_unicode_environment (void)
{
this->use_unicode_environment_ = false;
}
ACE_INLINE bool
ACE_Process_Options::use_unicode_environment (void) const
{
return this->use_unicode_environment_;
}
#if defined (ACE_WIN32)
ACE_INLINE PROCESS_INFORMATION
ACE_Process::process_info (void)
{
return process_info_;
}
#endif /* ACE_WIN32 */
ACE_INLINE ACE_HANDLE
ACE_Process::gethandle (void) const
{
#if defined (ACE_WIN32)
return process_info_.hProcess;
#else
return ACE_HANDLE (child_id_);
#endif /* ACE_WIN32 */
}
ACE_INLINE pid_t
ACE_Process::getpid (void)
const
{
#if defined (ACE_WIN32)
return process_info_.dwProcessId;
#else /* ACE_WIN32 */
return child_id_;
#endif /* ACE_WIN32 */
}
ACE_INLINE pid_t
ACE_Process::wait (ACE_exitcode *status,
int wait_options)
{
pid_t retv =
ACE_OS::wait (this->getpid (),
&this->exit_code_,
wait_options
#if defined (ACE_WIN32)
, process_info_.hProcess
#endif /* ACE_WIN32 */
);
if (status != 0)
*status = this->exit_code_;
return retv;
}
ACE_INLINE int
ACE_Process::kill (int signum)
{
if (this->getpid () != -1)
return ACE_OS::kill (this->getpid (), signum);
else
return -1;
}
ACE_INLINE int
ACE_Process::terminate (void)
{
if (this->getpid () != -1)
return ACE::terminate_process (this->getpid ());
else
return -1;
}
ACE_INLINE int
ACE_Process::return_value (void) const
{
#if defined (ACE_WIN32)
return this->exit_code_;
#else
return WEXITSTATUS (this->exit_code_);
#endif /* ACE_WIN32 */
}
ACE_INLINE ACE_exitcode
ACE_Process::exit_code (void) const
{
return this->exit_code_;
}
ACE_INLINE void
ACE_Process::exit_code (ACE_exitcode code)
{
this->exit_code_ = code;
}
ACE_INLINE u_long
ACE_Process_Options::creation_flags (void) const
{
#if defined (ACE_USES_WCHAR) && defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
return creation_flags_ | CREATE_UNICODE_ENVIRONMENT;
#else
return creation_flags_;
#endif /* ACE_USES_WCHAR */
}
ACE_INLINE void
ACE_Process_Options::creation_flags (u_long cf)
{
creation_flags_ = cf;
}
ACE_INLINE pid_t
ACE_Process_Options::getgroup (void) const
{
return process_group_;
}
ACE_INLINE pid_t
ACE_Process_Options::setgroup (pid_t pgrp)
{
pid_t old = process_group_;
process_group_ = pgrp;
return old;
}
ACE_INLINE int
ACE_Process_Options::handle_inheritance (void)
{
return handle_inheritance_;
}
ACE_INLINE void
ACE_Process_Options::handle_inheritance (int hi)
{
handle_inheritance_ = hi;
}
ACE_INLINE int
ACE_Process_Options::avoid_zombies (void)
{
return avoid_zombies_;
}
ACE_INLINE void
ACE_Process_Options::avoid_zombies (int avoid_zombies)
{
avoid_zombies_ = avoid_zombies;
}
#if defined (ACE_WIN32)
ACE_INLINE ACE_TEXT_STARTUPINFO *
ACE_Process_Options::startup_info (void)
{
#if !defined (ACE_HAS_WINCE)
return &startup_info_;
#else
return 0;
#endif /* !ACE_HAS_WINCE */
}
ACE_INLINE LPSECURITY_ATTRIBUTES
ACE_Process_Options::get_process_attributes (void) const
{
#if !defined (ACE_HAS_WINCE)
return process_attributes_;
#else
return 0;
#endif /* !ACE_HAS_WINCE */
}
ACE_INLINE LPSECURITY_ATTRIBUTES
ACE_Process_Options::set_process_attributes (void)
{
#if !defined (ACE_HAS_WINCE)
process_attributes_ = &security_buf1_;
return process_attributes_;
#else
return 0;
#endif /* !ACE_HAS_WINCE */
}
ACE_INLINE LPSECURITY_ATTRIBUTES
ACE_Process_Options::get_thread_attributes (void) const
{
#if !defined (ACE_HAS_WINCE)
return thread_attributes_;
#else
return 0;
#endif /* !ACE_HAS_WINCE */
}
ACE_INLINE LPSECURITY_ATTRIBUTES
ACE_Process_Options::set_thread_attributes (void)
{
#if !defined (ACE_HAS_WINCE)
thread_attributes_ = &security_buf2_;
return thread_attributes_;
#else
return 0;
#endif /* !ACE_HAS_WINCE */
}
#else /* !defined (ACE_WIN32) */
ACE_INLINE ACE_HANDLE
ACE_Process_Options::get_stdin (void) const
{
return stdin_;
}
ACE_INLINE ACE_HANDLE
ACE_Process_Options::get_stdout (void) const
{
return stdout_;
}
ACE_INLINE ACE_HANDLE
ACE_Process_Options::get_stderr (void) const
{
return stderr_;
}
ACE_INLINE bool
ACE_Process_Options::inherit_environment (void) const
{
return inherit_environment_;
}
ACE_INLINE void
ACE_Process_Options::inherit_environment (bool nv)
{
inherit_environment_ = nv;
}
ACE_INLINE int
ACE_Process_Options::setreugid (const ACE_TCHAR* user)
{
#if !defined (ACE_LACKS_PWD_FUNCTIONS)
struct passwd *ent = ACE_OS::getpwnam (ACE_TEXT_ALWAYS_CHAR (user));
if (ent != 0)
{
this->euid_ = ent->pw_uid;
this->ruid_ = ent->pw_uid;
this->egid_ = ent->pw_gid;
this->rgid_ = ent->pw_gid;
return 0;
}
else
return -1;
#else
ACE_UNUSED_ARG (user);
ACE_NOTSUP_RETURN (-1);
#endif /* ACE_LACKS_PWD_FUNCTIONS */
}
ACE_INLINE void
ACE_Process_Options::setruid (uid_t id)
{
this->ruid_ = id;
}
ACE_INLINE void
ACE_Process_Options::seteuid (uid_t id)
{
this->euid_ = id;
}
ACE_INLINE void
ACE_Process_Options::setrgid (uid_t id)
{
this->rgid_ = id;
}
ACE_INLINE void
ACE_Process_Options::setegid (uid_t id)
{
this->egid_ = id;
}
ACE_INLINE uid_t
ACE_Process_Options::getruid (void) const
{
return this->ruid_;
}
ACE_INLINE uid_t
ACE_Process_Options::geteuid (void) const
{
return this->euid_;
}
ACE_INLINE uid_t
ACE_Process_Options::getrgid (void) const
{
return this->rgid_;
}
ACE_INLINE uid_t
ACE_Process_Options::getegid (void) const
{
return this->egid_;
}
#endif /* ACE_WIN32 */
ACE_INLINE ACE_TCHAR *
ACE_Process_Options::command_line_buf (int *max_lenp)
{
if (max_lenp != 0)
*max_lenp = this->command_line_buf_len_;
return this->command_line_buf_;
}
ACE_INLINE ACE_TCHAR *
ACE_Process_Options::working_directory (void)
{
#if !defined (ACE_HAS_WINCE)
if (working_directory_[0] == '\0')
return 0;
else
return working_directory_;
#else
return 0;
#endif /* !ACE_HAS_WINCE */
}
ACE_INLINE void
ACE_Process_Options::working_directory (const char *wd)
{
#if !defined(ACE_HAS_WINCE)
ACE_OS::strcpy (working_directory_, ACE_TEXT_CHAR_TO_TCHAR (wd));
#else
ACE_UNUSED_ARG (wd);
#endif /* !ACE_HAS_WINCE */
}
#if defined (ACE_HAS_WCHAR)
ACE_INLINE void
ACE_Process_Options::working_directory (const wchar_t *wd)
{
#if !defined(ACE_HAS_WINCE)
ACE_OS::strcpy (working_directory_, ACE_TEXT_WCHAR_TO_TCHAR (wd));
#else
ACE_UNUSED_ARG (wd);
#endif /* !ACE_HAS_WINCE */
}
#endif /* ACE_HAS_WCHAR */
ACE_INLINE void
ACE_Process_Options::process_name (const ACE_TCHAR *p)
{
ACE_OS::strcpy (this->process_name_, p);
}
ACE_INLINE const ACE_TCHAR *
ACE_Process_Options::process_name (void)
{
if (process_name_[0] == '\0')
this->process_name (this->command_line_argv ()[0]);
return this->process_name_;
}
#if defined (ACE_HAS_WINCE)
// Here is a collection of inline functions which are defined only
// under CE. They are not empty on most other platforms.
ACE_INLINE int
ACE_Process_Options::setenv (ACE_TCHAR * /* envp */[])
{
return -1;
}
ACE_INLINE int
ACE_Process_Options::setenv (const ACE_TCHAR * /* format */, ...)
{
return -1;
}
ACE_INLINE int
ACE_Process_Options::setenv (const ACE_TCHAR * /* variable_name */,
const ACE_TCHAR * /* format */,
...)
{
return -1;
}
ACE_INLINE int
ACE_Process_Options::set_handles (ACE_HANDLE /* std_in */,
ACE_HANDLE /* std_out */,
ACE_HANDLE /* std_err */)
{
return -1;
}
#endif /* ACE_HAS_WINCE */
ACE_END_VERSIONED_NAMESPACE_DECL
|