@@ -249,47 +249,6 @@ static void write_pid_file(std::string &pid_path, uint64_t pid)
249249 pid_file.write (reinterpret_cast <char *>(&pid), sizeof (pid));
250250}
251251
252- #elif defined(__APPLE__)
253- enum TimeoutResult { Success, Error, Timeout };
254-
255- TimeoutResult wait_with_timeout (pid_t target_pid, int timeout_seconds, int sleepIntervalSeconds)
256- {
257- TimeoutResult result = TimeoutResult::Timeout;
258-
259- auto start = std::chrono::steady_clock::now ();
260- auto end = start + std::chrono::seconds (timeout_seconds);
261-
262- do {
263- int kill_result = kill (target_pid, 0 );
264-
265- if (kill_result == -1 ) {
266- if (errno == EINTR ) {
267- continue ;
268- }
269- if (errno == ESRCH ) {
270- result = TimeoutResult::Success;
271- break ;
272- }
273- result = TimeoutResult::Error;
274- break ;
275- }
276-
277- auto now = std::chrono::steady_clock::now ();
278- if (now >= end)
279- break ;
280-
281- auto remaining = end - now;
282- auto remaining_seconds = std::chrono::duration_cast<std::chrono::seconds>(remaining);
283-
284- auto sleep_duration = std::min (remaining_seconds, std::chrono::seconds (sleepIntervalSeconds));
285-
286- std::this_thread::sleep_for (sleep_duration);
287-
288- } while (true );
289-
290- return result;
291- }
292-
293252#endif
294253
295254Controller::Controller () {}
@@ -350,20 +309,8 @@ std::shared_ptr<ipc::client> Controller::host(const std::string &uri)
350309 int st = proc_pidinfo (pids[i], PROC_PIDTBSDINFO , 0 , &proc, PROC_PIDTBSDINFO_SIZE );
351310 if (st == PROC_PIDTBSDINFO_SIZE ) {
352311 if (strcmp (" obs64" , proc.pbi_name ) == 0 ) {
353- if (pids[i] != 0 ) {
354- if (kill (pids[i], SIGKILL ) == 0 ) {
355- TimeoutResult waitPidResult = wait_with_timeout (pids[i], processTimeoutSeconds, sleepIntervalSeconds);
356- switch (waitPidResult) {
357- case TimeoutResult::Error:
358- std::cout << " waitPidResult had an error" << std::endl;
359- break ;
360- case TimeoutResult::Timeout:
361- std::cout << " waitPidResult could not close the PID before the timeout" << std::endl;
362- break ;
363- case TimeoutResult::Success:
364- break ;
365- }
366- }
312+ if (pids[i] != 0 && kill (pids[i], SIGKILL ) != 0 ) {
313+ std::cout << " Warning: could not kill orphaned/former obs64 process" << std::endl;
367314 }
368315 }
369316 }
0 commit comments