VirtualBox

source: vbox/trunk/src/VBox/Runtime/r3/posix/process-creation-posix.cpp@ 34079

Last change on this file since 34079 was 33772, checked in by vboxsync, 14 years ago

process-creation-posix.cpp: Don't assert when the executable file doesn't exist or isn't executable.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 22.3 KB
Line 
1/* $Id: process-creation-posix.cpp 33772 2010-11-04 14:59:15Z vboxsync $ */
2/** @file
3 * IPRT - Process Creation, POSIX.
4 */
5
6/*
7 * Copyright (C) 2006-2010 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27
28/*******************************************************************************
29* Header Files *
30*******************************************************************************/
31#define LOG_GROUP RTLOGGROUP_PROCESS
32#include <unistd.h>
33#include <stdlib.h>
34#include <errno.h>
35#include <sys/types.h>
36#include <sys/stat.h>
37#include <sys/wait.h>
38#include <fcntl.h>
39#include <signal.h>
40#if defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS)
41# include <crypt.h>
42# include <pwd.h>
43# include <shadow.h>
44#endif
45#if defined(RT_OS_LINUX) || defined(RT_OS_OS2)
46/* While Solaris has posix_spawn() of course we don't want to use it as
47 * we need to have the child in a different process contract, no matter
48 * whether it is started detached or not. */
49# define HAVE_POSIX_SPAWN 1
50#endif
51#ifdef HAVE_POSIX_SPAWN
52# include <spawn.h>
53#endif
54#ifdef RT_OS_DARWIN
55# include <mach-o/dyld.h>
56#endif
57#ifdef RT_OS_SOLARIS
58# include <limits.h>
59# include <sys/ctfs.h>
60# include <sys/contract/process.h>
61# include <libcontract.h>
62#endif
63
64#include <iprt/process.h>
65#include "internal/iprt.h"
66
67#include <iprt/assert.h>
68#include <iprt/env.h>
69#include <iprt/err.h>
70#include <iprt/file.h>
71#include <iprt/pipe.h>
72#include <iprt/socket.h>
73#include <iprt/string.h>
74#include <iprt/mem.h>
75#include "internal/process.h"
76
77
78/**
79 * Check the credentials and return the gid/uid of user.
80 *
81 * @param pszUser username
82 * @param pszPasswd password
83 * @param gid where to store the GID of the user
84 * @param uid where to store the UID of the user
85 * @returns IPRT status code
86 */
87static int rtCheckCredentials(const char *pszUser, const char *pszPasswd, gid_t *gid, uid_t *uid)
88{
89#if defined(RT_OS_LINUX)
90 struct passwd *pw;
91
92 pw = getpwnam(pszUser);
93 if (!pw)
94 return VERR_PERMISSION_DENIED;
95
96 if (!pszPasswd)
97 pszPasswd = "";
98
99 struct spwd *spwd;
100 /* works only if /etc/shadow is accessible */
101 spwd = getspnam(pszUser);
102 if (spwd)
103 pw->pw_passwd = spwd->sp_pwdp;
104
105 /* be reentrant */
106 struct crypt_data *data = (struct crypt_data*)RTMemTmpAllocZ(sizeof(*data));
107 char *pszEncPasswd = crypt_r(pszPasswd, pw->pw_passwd, data);
108 if (strcmp(pszEncPasswd, pw->pw_passwd))
109 return VERR_PERMISSION_DENIED;
110 RTMemTmpFree(data);
111
112 *gid = pw->pw_gid;
113 *uid = pw->pw_uid;
114 return VINF_SUCCESS;
115
116#elif defined(RT_OS_SOLARIS)
117 struct passwd *ppw, pw;
118 char szBuf[1024];
119
120 if (getpwnam_r(pszUser, &pw, szBuf, sizeof(szBuf), &ppw) != 0 || ppw == NULL)
121 return VERR_PERMISSION_DENIED;
122
123 if (!pszPasswd)
124 pszPasswd = "";
125
126 struct spwd spwd;
127 char szPwdBuf[1024];
128 /* works only if /etc/shadow is accessible */
129 if (getspnam_r(pszUser, &spwd, szPwdBuf, sizeof(szPwdBuf)) != NULL)
130 ppw->pw_passwd = spwd.sp_pwdp;
131
132 char *pszEncPasswd = crypt(pszPasswd, ppw->pw_passwd);
133 if (strcmp(pszEncPasswd, ppw->pw_passwd))
134 return VERR_PERMISSION_DENIED;
135
136 *gid = ppw->pw_gid;
137 *uid = ppw->pw_uid;
138 return VINF_SUCCESS;
139
140#else
141 return VERR_PERMISSION_DENIED;
142#endif
143}
144
145
146#ifdef RT_OS_SOLARIS
147/** @todo the error reporting of the Solaris process contract code could be
148 * a lot better, but essentially it is not meant to run into errors after
149 * the debugging phase. */
150static int rtSolarisContractPreFork(void)
151{
152 int templateFd = open64(CTFS_ROOT "/process/template", O_RDWR);
153 if (templateFd < 0)
154 return -1;
155
156 /* Set template parameters and event sets. */
157 if (ct_pr_tmpl_set_param(templateFd, CT_PR_PGRPONLY))
158 {
159 close(templateFd);
160 return -1;
161 }
162 if (ct_pr_tmpl_set_fatal(templateFd, CT_PR_EV_HWERR))
163 {
164 close(templateFd);
165 return -1;
166 }
167 if (ct_tmpl_set_critical(templateFd, 0))
168 {
169 close(templateFd);
170 return -1;
171 }
172 if (ct_tmpl_set_informative(templateFd, CT_PR_EV_HWERR))
173 {
174 close(templateFd);
175 return -1;
176 }
177
178 /* Make this the active template for the process. */
179 if (ct_tmpl_activate(templateFd))
180 {
181 close(templateFd);
182 return -1;
183 }
184
185 return templateFd;
186}
187
188static void rtSolarisContractPostForkChild(int templateFd)
189{
190 if (templateFd == -1)
191 return;
192
193 /* Clear the active template. */
194 ct_tmpl_clear(templateFd);
195 close(templateFd);
196}
197
198static void rtSolarisContractPostForkParent(int templateFd, pid_t pid)
199{
200 if (templateFd == -1)
201 return;
202
203 /* Clear the active template. */
204 int cleared = ct_tmpl_clear(templateFd);
205 close(templateFd);
206
207 /* If the clearing failed or the fork failed there's nothing more to do. */
208 if (cleared || pid <= 0)
209 return;
210
211 /* Look up the contract which was created by this thread. */
212 int statFd = open64(CTFS_ROOT "/process/latest", O_RDONLY);
213 if (statFd == -1)
214 return;
215 ct_stathdl_t statHdl;
216 if (ct_status_read(statFd, CTD_COMMON, &statHdl))
217 {
218 close(statFd);
219 return;
220 }
221 ctid_t ctId = ct_status_get_id(statHdl);
222 ct_status_free(statHdl);
223 close(statFd);
224 if (ctId < 0)
225 return;
226
227 /* Abandon this contract we just created. */
228 char ctlPath[PATH_MAX];
229 size_t len = snprintf(ctlPath, sizeof(ctlPath),
230 CTFS_ROOT "/process/%d/ctl", ctId);
231 if (len >= sizeof(ctlPath))
232 return;
233 int ctlFd = open64(ctlPath, O_WRONLY);
234 if (statFd == -1)
235 return;
236 if (ct_ctl_abandon(ctlFd) < 0)
237 {
238 close(ctlFd);
239 return;
240 }
241 close(ctlFd);
242}
243
244#endif /* RT_OS_SOLARIS */
245
246
247RTR3DECL(int) RTProcCreate(const char *pszExec, const char * const *papszArgs, RTENV Env, unsigned fFlags, PRTPROCESS pProcess)
248{
249 return RTProcCreateEx(pszExec, papszArgs, Env, fFlags,
250 NULL, NULL, NULL, /* standard handles */
251 NULL /*pszAsUser*/, NULL /* pszPassword*/,
252 pProcess);
253}
254
255
256RTR3DECL(int) RTProcCreateEx(const char *pszExec, const char * const *papszArgs, RTENV hEnv, uint32_t fFlags,
257 PCRTHANDLE phStdIn, PCRTHANDLE phStdOut, PCRTHANDLE phStdErr, const char *pszAsUser,
258 const char *pszPassword, PRTPROCESS phProcess)
259{
260 int rc;
261
262 /*
263 * Input validation
264 */
265 AssertPtrReturn(pszExec, VERR_INVALID_POINTER);
266 AssertReturn(*pszExec, VERR_INVALID_PARAMETER);
267 AssertReturn(!(fFlags & ~(RTPROC_FLAGS_DETACHED | RTPROC_FLAGS_SERVICE)), VERR_INVALID_PARAMETER);
268 AssertReturn(!(fFlags & RTPROC_FLAGS_DETACHED) || !phProcess, VERR_INVALID_PARAMETER);
269 AssertReturn(hEnv != NIL_RTENV, VERR_INVALID_PARAMETER);
270 const char * const *papszEnv = RTEnvGetExecEnvP(hEnv);
271 AssertPtrReturn(papszEnv, VERR_INVALID_HANDLE);
272 AssertPtrReturn(papszArgs, VERR_INVALID_PARAMETER);
273 /** @todo search the PATH (add flag for this). */
274 AssertPtrNullReturn(pszAsUser, VERR_INVALID_POINTER);
275 AssertReturn(!pszAsUser || *pszAsUser, VERR_INVALID_PARAMETER);
276 AssertReturn(!pszPassword || pszAsUser, VERR_INVALID_PARAMETER);
277 AssertPtrNullReturn(pszPassword, VERR_INVALID_POINTER);
278
279 /*
280 * Get the file descriptors for the handles we've been passed.
281 */
282 PCRTHANDLE paHandles[3] = { phStdIn, phStdOut, phStdErr };
283 int aStdFds[3] = { -1, -1, -1 };
284 for (int i = 0; i < 3; i++)
285 {
286 if (paHandles[i])
287 {
288 AssertPtrReturn(paHandles[i], VERR_INVALID_POINTER);
289 switch (paHandles[i]->enmType)
290 {
291 case RTHANDLETYPE_FILE:
292 aStdFds[i] = paHandles[i]->u.hFile != NIL_RTFILE
293 ? (int)RTFileToNative(paHandles[i]->u.hFile)
294 : -2 /* close it */;
295 break;
296
297 case RTHANDLETYPE_PIPE:
298 aStdFds[i] = paHandles[i]->u.hPipe != NIL_RTPIPE
299 ? (int)RTPipeToNative(paHandles[i]->u.hPipe)
300 : -2 /* close it */;
301 break;
302
303 case RTHANDLETYPE_SOCKET:
304 aStdFds[i] = paHandles[i]->u.hSocket != NIL_RTSOCKET
305 ? (int)RTSocketToNative(paHandles[i]->u.hSocket)
306 : -2 /* close it */;
307 break;
308
309 default:
310 AssertMsgFailedReturn(("%d: %d\n", i, paHandles[i]->enmType), VERR_INVALID_PARAMETER);
311 }
312 /** @todo check the close-on-execness of these handles? */
313 }
314 }
315
316 for (int i = 0; i < 3; i++)
317 if (aStdFds[i] == i)
318 aStdFds[i] = -1;
319
320 for (int i = 0; i < 3; i++)
321 AssertMsgReturn(aStdFds[i] < 0 || aStdFds[i] > i,
322 ("%i := %i not possible because we're lazy\n", i, aStdFds[i]),
323 VERR_NOT_SUPPORTED);
324
325 /*
326 * Resolve the user id if specified.
327 */
328 uid_t uid = ~(uid_t)0;
329 gid_t gid = ~(gid_t)0;
330 if (pszAsUser)
331 {
332 rc = rtCheckCredentials(pszAsUser, pszPassword, &gid, &uid);
333 if (RT_FAILURE(rc))
334 return rc;
335 }
336
337 /*
338 * Check for execute access to the file.
339 */
340 if (access(pszExec, X_OK))
341 return RTErrConvertFromErrno(errno);
342
343 pid_t pid = -1;
344
345 /*
346 * Take care of detaching the process.
347 *
348 * HACK ALERT! Put the process into a new process group with pgid = pid
349 * to make sure it differs from that of the parent process to ensure that
350 * the IPRT waitpid call doesn't race anyone (read XPCOM) doing group wide
351 * waits. setsid() includes the setpgid() functionality.
352 * 2010-10-11 XPCOM no longer waits for anything, but it cannot hurt.
353 */
354#ifndef RT_OS_OS2
355 if (fFlags & RTPROC_FLAGS_DETACHED)
356 {
357# ifdef RT_OS_SOLARIS
358 int templateFd = rtSolarisContractPreFork();
359 if (templateFd == -1)
360 return VERR_OPEN_FAILED;
361# endif /* RT_OS_SOLARIS */
362 pid = fork();
363 if (!pid)
364 {
365# ifdef RT_OS_SOLARIS
366 rtSolarisContractPostForkChild(templateFd);
367# endif /* RT_OS_SOLARIS */
368 setsid(); /* see comment above */
369
370 pid = -1;
371 /* Child falls through to the actual spawn code below. */
372 }
373 else
374 {
375#ifdef RT_OS_SOLARIS
376 rtSolarisContractPostForkParent(templateFd, pid);
377#endif /* RT_OS_SOLARIS */
378 if (pid > 0)
379 {
380 /* Must wait for the temporary process to avoid a zombie. */
381 int status = 0;
382 pid_t pidChild = 0;
383
384 /* Restart if we get interrupted. */
385 do
386 {
387 pidChild = waitpid(pid, &status, 0);
388 } while ( pidChild == -1
389 && errno == EINTR);
390
391 /* Assume that something wasn't found. No detailed info. */
392 if (status)
393 return VERR_PROCESS_NOT_FOUND;
394 if (phProcess)
395 *phProcess = 0;
396 return VINF_SUCCESS;
397 }
398 return RTErrConvertFromErrno(errno);
399 }
400 }
401#endif
402
403 /*
404 * Spawn the child.
405 *
406 * Any spawn code MUST not execute any atexit functions if it is for a
407 * detached process. It would lead to running the atexit functions which
408 * make only sense for the parent. libORBit e.g. gets confused by multiple
409 * execution. Remember, there was only a fork() so far, and until exec()
410 * is successfully run there is nothing which would prevent doing anything
411 * silly with the (duplicated) file descriptors.
412 */
413#ifdef HAVE_POSIX_SPAWN
414 /** @todo OS/2: implement DETACHED (BACKGROUND stuff), see VbglR3Daemonize. */
415 if ( uid == ~(uid_t)0
416 && gid == ~(gid_t)0)
417 {
418 /* Spawn attributes. */
419 posix_spawnattr_t Attr;
420 rc = posix_spawnattr_init(&Attr);
421 if (!rc)
422 {
423# ifndef RT_OS_OS2 /* We don't need this on OS/2 and I don't recall if it's actually implemented. */
424 rc = posix_spawnattr_setflags(&Attr, POSIX_SPAWN_SETPGROUP);
425 Assert(rc == 0);
426 if (!rc)
427 {
428 rc = posix_spawnattr_setpgroup(&Attr, 0 /* pg == child pid */);
429 Assert(rc == 0);
430 }
431# endif
432
433 /* File changes. */
434 posix_spawn_file_actions_t FileActions;
435 posix_spawn_file_actions_t *pFileActions = NULL;
436 if (aStdFds[0] != -1 || aStdFds[1] != -1 || aStdFds[2] != -1)
437 {
438 rc = posix_spawn_file_actions_init(&FileActions);
439 if (!rc)
440 {
441 pFileActions = &FileActions;
442 for (int i = 0; i < 3; i++)
443 {
444 int fd = aStdFds[i];
445 if (fd == -2)
446 rc = posix_spawn_file_actions_addclose(&FileActions, i);
447 else if (fd >= 0 && fd != i)
448 {
449 rc = posix_spawn_file_actions_adddup2(&FileActions, fd, i);
450 if (!rc)
451 {
452 for (int j = i + 1; j < 3; j++)
453 if (aStdFds[j] == fd)
454 {
455 fd = -1;
456 break;
457 }
458 if (fd >= 0)
459 rc = posix_spawn_file_actions_addclose(&FileActions, fd);
460 }
461 }
462 if (rc)
463 break;
464 }
465 }
466 }
467
468 if (!rc)
469 rc = posix_spawn(&pid, pszExec, pFileActions, &Attr, (char * const *)papszArgs,
470 (char * const *)papszEnv);
471
472 /* cleanup */
473 int rc2 = posix_spawnattr_destroy(&Attr); Assert(rc2 == 0); NOREF(rc2);
474 if (pFileActions)
475 {
476 rc2 = posix_spawn_file_actions_destroy(pFileActions);
477 Assert(rc2 == 0);
478 }
479
480 /* return on success.*/
481 if (!rc)
482 {
483 /* For a detached process this happens in the temp process, so
484 * it's not worth doing anything as this process must exit. */
485 if (fFlags & RTPROC_FLAGS_DETACHED)
486 _Exit(0);
487 if (phProcess)
488 *phProcess = pid;
489 return VINF_SUCCESS;
490 }
491 }
492 /* For a detached process this happens in the temp process, so
493 * it's not worth doing anything as this process must exit. */
494 if (fFlags & RTPROC_FLAGS_DETACHED)
495 _Exit(124);
496 }
497 else
498#endif
499 {
500#ifdef RT_OS_SOLARIS
501 int templateFd = rtSolarisContractPreFork();
502 if (templateFd == -1)
503 return VERR_OPEN_FAILED;
504#endif /* RT_OS_SOLARIS */
505 pid = fork();
506 if (!pid)
507 {
508#ifdef RT_OS_SOLARIS
509 rtSolarisContractPostForkChild(templateFd);
510#endif /* RT_OS_SOLARIS */
511 if (!(fFlags & RTPROC_FLAGS_DETACHED))
512 setpgid(0, 0); /* see comment above */
513
514 /*
515 * Change group and user if requested.
516 */
517#if 1 /** @todo This needs more work, see suplib/hardening. */
518 if (gid != ~(gid_t)0)
519 {
520 if (setgid(gid))
521 {
522 if (fFlags & RTPROC_FLAGS_DETACHED)
523 _Exit(126);
524 else
525 exit(126);
526 }
527 }
528
529 if (uid != ~(uid_t)0)
530 {
531 if (setuid(uid))
532 {
533 if (fFlags & RTPROC_FLAGS_DETACHED)
534 _Exit(126);
535 else
536 exit(126);
537 }
538 }
539#endif
540
541 /*
542 * Apply changes to the standard file descriptor and stuff.
543 */
544 for (int i = 0; i < 3; i++)
545 {
546 int fd = aStdFds[i];
547 if (fd == -2)
548 close(i);
549 else if (fd >= 0)
550 {
551 int rc2 = dup2(fd, i);
552 if (rc2 != i)
553 {
554 if (fFlags & RTPROC_FLAGS_DETACHED)
555 _Exit(125);
556 else
557 exit(125);
558 }
559 for (int j = i + 1; j < 3; j++)
560 if (aStdFds[j] == fd)
561 {
562 fd = -1;
563 break;
564 }
565 if (fd >= 0)
566 close(fd);
567 }
568 }
569
570 /*
571 * Finally, execute the requested program.
572 */
573 rc = execve(pszExec, (char * const *)papszArgs, (char * const *)papszEnv);
574 if (errno == ENOEXEC)
575 {
576 /* This can happen when trying to start a shell script without the magic #!/bin/sh */
577 RTAssertMsg2Weak("Cannot execute this binary format!\n");
578 }
579 else
580 RTAssertMsg2Weak("execve returns %d errno=%d\n", rc, errno);
581 RTAssertReleasePanic();
582 if (fFlags & RTPROC_FLAGS_DETACHED)
583 _Exit(127);
584 else
585 exit(127);
586 }
587#ifdef RT_OS_SOLARIS
588 rtSolarisContractPostForkParent(templateFd, pid);
589#endif /* RT_OS_SOLARIS */
590 if (pid > 0)
591 {
592 /* For a detached process this happens in the temp process, so
593 * it's not worth doing anything as this process must exit. */
594 if (fFlags & RTPROC_FLAGS_DETACHED)
595 _Exit(0);
596 if (phProcess)
597 *phProcess = pid;
598 return VINF_SUCCESS;
599 }
600 /* For a detached process this happens in the temp process, so
601 * it's not worth doing anything as this process must exit. */
602 if (fFlags & RTPROC_FLAGS_DETACHED)
603 _Exit(124);
604 return RTErrConvertFromErrno(errno);
605 }
606
607 return VERR_NOT_IMPLEMENTED;
608}
609
610
611RTR3DECL(int) RTProcDaemonizeUsingFork(bool fNoChDir, bool fNoClose, const char *pszPidfile)
612{
613 /*
614 * Fork the child process in a new session and quit the parent.
615 *
616 * - fork once and create a new session (setsid). This will detach us
617 * from the controlling tty meaning that we won't receive the SIGHUP
618 * (or any other signal) sent to that session.
619 * - The SIGHUP signal is ignored because the session/parent may throw
620 * us one before we get to the setsid.
621 * - When the parent exit(0) we will become an orphan and re-parented to
622 * the init process.
623 * - Because of the sometimes unexpected semantics of assigning the
624 * controlling tty automagically when a session leader first opens a tty,
625 * we will fork() once more to get rid of the session leadership role.
626 */
627
628 /* We start off by opening the pidfile, so that we can fail straight away
629 * if it already exists. */
630 int fdPidfile = -1;
631 if (pszPidfile != NULL)
632 {
633 /* @note the exclusive create is not guaranteed on all file
634 * systems (e.g. NFSv2) */
635 if ((fdPidfile = open(pszPidfile, O_RDWR | O_CREAT | O_EXCL, 0644)) == -1)
636 return RTErrConvertFromErrno(errno);
637 }
638
639 /* Ignore SIGHUP straight away. */
640 struct sigaction OldSigAct;
641 struct sigaction SigAct;
642 memset(&SigAct, 0, sizeof(SigAct));
643 SigAct.sa_handler = SIG_IGN;
644 int rcSigAct = sigaction(SIGHUP, &SigAct, &OldSigAct);
645
646 /* First fork, to become independent process. */
647 pid_t pid = fork();
648 if (pid == -1)
649 return RTErrConvertFromErrno(errno);
650 if (pid != 0)
651 {
652 /* Parent exits, no longer necessary. The child gets reparented
653 * to the init process. */
654 exit(0);
655 }
656
657 /* Create new session, fix up the standard file descriptors and the
658 * current working directory. */
659 pid_t newpgid = setsid();
660 int SavedErrno = errno;
661 if (rcSigAct != -1)
662 sigaction(SIGHUP, &OldSigAct, NULL);
663 if (newpgid == -1)
664 return RTErrConvertFromErrno(SavedErrno);
665
666 if (!fNoClose)
667 {
668 /* Open stdin(0), stdout(1) and stderr(2) as /dev/null. */
669 int fd = open("/dev/null", O_RDWR);
670 if (fd == -1) /* paranoia */
671 {
672 close(STDIN_FILENO);
673 close(STDOUT_FILENO);
674 close(STDERR_FILENO);
675 fd = open("/dev/null", O_RDWR);
676 }
677 if (fd != -1)
678 {
679 dup2(fd, STDIN_FILENO);
680 dup2(fd, STDOUT_FILENO);
681 dup2(fd, STDERR_FILENO);
682 if (fd > 2)
683 close(fd);
684 }
685 }
686
687 if (!fNoChDir)
688 {
689 int rcChdir = chdir("/");
690 }
691
692 /* Second fork to lose session leader status. */
693 pid = fork();
694 if (pid == -1)
695 return RTErrConvertFromErrno(errno);
696
697 if (pid != 0)
698 {
699 /* Write the pid file, this is done in the parent, before exiting. */
700 if (fdPidfile != -1)
701 {
702 char szBuf[256];
703 size_t cbPid = RTStrPrintf(szBuf, sizeof(szBuf), "%d\n", pid);
704 int rcWrite = write(fdPidfile, szBuf, cbPid);
705 close(fdPidfile);
706 }
707 exit(0);
708 }
709
710 return VINF_SUCCESS;
711}
712
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette