50 {
52 int processStatus( 0 );
53
54 int returnValue( 0 );
55
56 bool subprocessReturned( true );
57
58 int forkReturnValue( fork() );
59 if( 0 > forkReturnValue )
60
61 {
62 std::cout
63 << std::endl
64 << "BOL::error! WaitingOnSubprocessExecutor::forkAndExecvAndWait() was"
65 << " unable to create the subprocess; there was an error and fork()"
66 << " returned " << forkReturnValue << std::endl;
67
68 }
69 else if( 0 == forkReturnValue )
70
71
72 {
75 {
76 std::cout
77 << std::endl
79 for( int argumentWritingCounter( 1 );
81 ++argumentWritingCounter )
82 {
83 std::cout
85 }
86 std::cout
87 << "\", with process id " << getpid() << ", real user id " << getuid()
88 << " & effective user id " << geteuid() << std::endl;
89 }
92
93 exit( returnValue );
94 }
95 else if( 0 < forkReturnValue )
96
97
98 {
99 bool subprocessFinished( false );
100
102 {
103 if( waitpid( forkReturnValue,
104 &processStatus,
105 WNOHANG ) == forkReturnValue )
106
107
108
109
110 {
112
113 subprocessFinished = true;
114
115 }
116 else
117 {
119
120 }
121 }
122 if( false == subprocessFinished )
123
124
125 {
127 {
128 std::cout
129 << std::endl
130 << "killing forked process " << forkReturnValue
131 <<
" due to it taking over " <<
patienceTicks <<
" milliseconds"
132 << std::endl;
133
134 }
135 kill( forkReturnValue,
136 9 );
137
138 waitpid( -1,
139 &processStatus,
140 0 );
141
142 subprocessReturned = false;
143
144
145 }
146 returnValue = WEXITSTATUS( processStatus );
147 }
148 return subprocessReturned;
149 }
static int const sleepingMicroseconds