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

Proposed by Brian Aker on 2013-06-28
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 2013-06-28 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
1=== modified file 'libtest/cmdline.cc'
2--- libtest/cmdline.cc 2013-06-02 09:00:13 +0000
3+++ libtest/cmdline.cc 2013-06-28 04:42:27 +0000
4@@ -437,9 +437,26 @@
5 #pragma GCC diagnostic ignored "-Wunreachable-code"
6 Application::error_t Application::join()
7 {
8- pid_t waited_pid= waitpid(_pid, &_status, 0);
9+ if (waitpid(_pid, &_status, 0) == -1)
10+ {
11+ std::string error_string;
12+ if (stdout_result_length())
13+ {
14+ error_string+= " stdout: ";
15+ error_string+= stdout_c_str();
16+ }
17+
18+ if (stderr_result_length())
19+ {
20+ error_string+= " stderr: ";
21+ error_string+= stderr_c_str();
22+ }
23+ Error << "waitpid() returned errno:" << strerror(errno) << " " << error_string;
24+ return Application::UNKNOWN;
25+ }
26+
27 slurp();
28- if (waited_pid == _pid and WIFEXITED(_status) == false)
29+ if (WIFEXITED(_status) == false)
30 {
31 /*
32 What we are looking for here is how the exit status happened.
33@@ -504,26 +521,9 @@
34 << " name:" << built_argv[0];
35 }
36 }
37- else if (waited_pid == _pid and WIFEXITED(_status))
38- {
39- _app_exit_state= int_to_error_t(WEXITSTATUS(_status));
40- }
41- else if (waited_pid == -1)
42- {
43- std::string error_string;
44- if (stdout_result_length())
45- {
46- error_string+= " stdout: ";
47- error_string+= stdout_c_str();
48- }
49-
50- if (stderr_result_length())
51- {
52- error_string+= " stderr: ";
53- error_string+= stderr_c_str();
54- }
55- Error << "waitpid() returned errno:" << strerror(errno) << " " << error_string;
56- _app_exit_state= Application::UNKNOWN;
57+ else if (WIFEXITED(_status))
58+ {
59+ return int_to_error_t(WEXITSTATUS(_status));
60 }
61 else
62 {
63
64=== modified file 'util/daemon.cc'
65--- util/daemon.cc 2012-10-28 20:04:35 +0000
66+++ util/daemon.cc 2013-06-28 04:42:27 +0000
67@@ -152,16 +152,16 @@
68 /* parent */
69 int exit_code= EXIT_FAILURE;
70 int status;
71- while (waitpid(child, &status, 0) != child)
72- { }
73-
74- if (WIFEXITED(status))
75- {
76- exit_code= WEXITSTATUS(status);
77- }
78- if (WIFSIGNALED(status))
79- {
80- exit_code= EXIT_FAILURE;
81+ if (waitpid(child, &status, 0) != -1)
82+ {
83+ if (WIFEXITED(status))
84+ {
85+ exit_code= WEXITSTATUS(status);
86+ }
87+ if (WIFSIGNALED(status))
88+ {
89+ exit_code= EXIT_FAILURE;
90+ }
91 }
92 _exit(exit_code);
93 }

Subscribers

People subscribed via source and target branches

to all changes: