Merge lp:~brianaker/gearmand/waitpid into lp:gearmand

Proposed by Brian Aker
Status: Merged
Merged at revision: 790
Proposed branch: lp:~brianaker/gearmand/waitpid
Merge into: lp:gearmand
Diff against target: 93 lines (+32/-32)
2 files modified
libtest/cmdline.cc (+22/-22)
util/daemon.cc (+10/-10)
To merge this branch: bzr merge lp:~brianaker/gearmand/waitpid
Reviewer Review Type Date Requested Status
Tangent Trunk Pending
Review via email: mp+171955@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'libtest/cmdline.cc'
--- libtest/cmdline.cc 2013-06-02 09:00:13 +0000
+++ libtest/cmdline.cc 2013-06-28 04:42:27 +0000
@@ -437,9 +437,26 @@
437#pragma GCC diagnostic ignored "-Wunreachable-code"437#pragma GCC diagnostic ignored "-Wunreachable-code"
438Application::error_t Application::join()438Application::error_t Application::join()
439{439{
440 pid_t waited_pid= waitpid(_pid, &_status, 0);440 if (waitpid(_pid, &_status, 0) == -1)
441 {
442 std::string error_string;
443 if (stdout_result_length())
444 {
445 error_string+= " stdout: ";
446 error_string+= stdout_c_str();
447 }
448
449 if (stderr_result_length())
450 {
451 error_string+= " stderr: ";
452 error_string+= stderr_c_str();
453 }
454 Error << "waitpid() returned errno:" << strerror(errno) << " " << error_string;
455 return Application::UNKNOWN;
456 }
457
441 slurp();458 slurp();
442 if (waited_pid == _pid and WIFEXITED(_status) == false)459 if (WIFEXITED(_status) == false)
443 {460 {
444 /*461 /*
445 What we are looking for here is how the exit status happened.462 What we are looking for here is how the exit status happened.
@@ -504,26 +521,9 @@
504 << " name:" << built_argv[0];521 << " name:" << built_argv[0];
505 }522 }
506 }523 }
507 else if (waited_pid == _pid and WIFEXITED(_status))524 else if (WIFEXITED(_status))
508 {525 {
509 _app_exit_state= int_to_error_t(WEXITSTATUS(_status));526 return int_to_error_t(WEXITSTATUS(_status));
510 }
511 else if (waited_pid == -1)
512 {
513 std::string error_string;
514 if (stdout_result_length())
515 {
516 error_string+= " stdout: ";
517 error_string+= stdout_c_str();
518 }
519
520 if (stderr_result_length())
521 {
522 error_string+= " stderr: ";
523 error_string+= stderr_c_str();
524 }
525 Error << "waitpid() returned errno:" << strerror(errno) << " " << error_string;
526 _app_exit_state= Application::UNKNOWN;
527 }527 }
528 else528 else
529 {529 {
530530
=== modified file 'util/daemon.cc'
--- util/daemon.cc 2012-10-28 20:04:35 +0000
+++ util/daemon.cc 2013-06-28 04:42:27 +0000
@@ -152,16 +152,16 @@
152 /* parent */152 /* parent */
153 int exit_code= EXIT_FAILURE;153 int exit_code= EXIT_FAILURE;
154 int status;154 int status;
155 while (waitpid(child, &status, 0) != child)155 if (waitpid(child, &status, 0) != -1)
156 { }156 {
157157 if (WIFEXITED(status))
158 if (WIFEXITED(status))158 {
159 {159 exit_code= WEXITSTATUS(status);
160 exit_code= WEXITSTATUS(status);160 }
161 }161 if (WIFSIGNALED(status))
162 if (WIFSIGNALED(status))162 {
163 {163 exit_code= EXIT_FAILURE;
164 exit_code= EXIT_FAILURE;164 }
165 }165 }
166 _exit(exit_code);166 _exit(exit_code);
167 }167 }

Subscribers

People subscribed via source and target branches

to all changes: