blocxx
WaitpidThreadFix.hpp
Go to the documentation of this file.
1#ifndef BLOCXX_WAITPID_THREAD_FIX_HPP_20060418
2#define BLOCXX_WAITPID_THREAD_FIX_HPP_20060418
3
4/*******************************************************************************
5* Copyright (C) 2005, Quest Software, Inc. All rights reserved.
6*
7* Redistribution and use in source and binary forms, with or without
8* modification, are permitted provided that the following conditions are met:
9*
10* * Redistributions of source code must retain the above copyright notice,
11* this list of conditions and the following disclaimer.
12* * Redistributions in binary form must reproduce the above copyright
13* notice, this list of conditions and the following disclaimer in the
14* documentation and/or other materials provided with the distribution.
15* * Neither the name of Quest Software, Inc., nor the
16* names of its contributors or employees may be used to endorse or promote
17* products derived from this software without specific prior written
18* permission.
19*
20* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30* POSSIBILITY OF SUCH DAMAGE.
31*******************************************************************************/
32
36
37#include "Types.hpp"
38#include "CommonFwd.hpp"
39#include "ThreadTypes.hpp"
40#include "blocxx/Process.hpp"
41
42namespace BLOCXX_NAMESPACE
43{
44
45/*******************************************************************************
46* Older linux threading libraries do not allow one thread to wait on the
47* children of another thread. This class is used by Exec and Process to work
48* around that limitation by having all calls to fork() and waitpid() done
49* by the same thread when BLOCXX_WAITPID_THREADING_PROBLEM is defined.
50*******************************************************************************/
52{
53
60 BLOCXX_COMMON_API bool setWaitpidThreadFixEnabled(bool enabled);
61
62 /*******************************************************************************
63 * Exec::spawn & Process::pollStatus will call this function
64 * to determine if WaitpidThreadFix should be used.
65 *******************************************************************************/
66 BLOCXX_COMMON_API bool shouldUseWaitpidThreadFix();
67
68 BLOCXX_COMMON_API ProcessRef spawnProcess(
69 char const * exec_path,
70 char const * const argv[],
71 char const * const envp[],
72 Exec::PreExec & pre_exec
73 );
74
75 BLOCXX_COMMON_API Process::Status waitPid(const ProcId& pid);
76
77} // end namespace WaitpidThreadFix
78
79
80} // namespace BLOCXX_NAMESPACE
81
82#endif // BLOCXX_WAITPID_THREAD_FIX_HPP_20060418
83
This class is used to specify what spawn() should do between fork and exec.
Definition Exec.hpp:106
Portable process status.
Definition Process.hpp:123
BLOCXX_COMMON_API ProcessRef spawnProcess(char const *exec_path, char const *const argv[], char const *const envp[], Exec::PreExec &pre_exec)
BLOCXX_COMMON_API Process::Status waitPid(const ProcId &pid)
BLOCXX_COMMON_API bool setWaitpidThreadFixEnabled(bool enabled)
If a program is single threaded (like the monitor code is), then this function can be called to ensur...
BLOCXX_COMMON_API bool shouldUseWaitpidThreadFix()
Taken from RFC 1321.
IntrusiveReference< Process > ProcessRef