diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-08-01 20:34:26 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-08-01 20:34:26 +0000 |
commit | 91d08e660237ff9a43476aabeb297daeaf9014ed (patch) | |
tree | 75a7ddc892f420f819a9acc88449836bd6d9f358 /src/util | |
parent | 83682f2d77f05ec8add6ed7e624a8b796baeaa36 (diff) | |
download | gnunet-91d08e660237ff9a43476aabeb297daeaf9014ed.tar.gz gnunet-91d08e660237ff9a43476aabeb297daeaf9014ed.zip |
LRN: Fix _kill() debugging and I/O interpretation
* Don't be verbose by default anymore - use #if DEBUG_OS
* Don't count a failure to write into a control pipe as an error
this DOES happen when the child is dead (which is how a utility
should be when it finishes)
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/os_priority.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/util/os_priority.c b/src/util/os_priority.c index 6097c9756..d214372d7 100644 --- a/src/util/os_priority.c +++ b/src/util/os_priority.c | |||
@@ -161,18 +161,29 @@ int | |||
161 | GNUNET_OS_process_kill (struct GNUNET_OS_Process *proc, int sig) | 161 | GNUNET_OS_process_kill (struct GNUNET_OS_Process *proc, int sig) |
162 | { | 162 | { |
163 | #if ENABLE_WINDOWS_WORKAROUNDS | 163 | #if ENABLE_WINDOWS_WORKAROUNDS |
164 | int res; | 164 | int res = 0; |
165 | int ret; | 165 | int ret = 0; |
166 | 166 | ||
167 | ret = GNUNET_DISK_file_write (proc->control_pipe, &sig, sizeof(sig)); | 167 | ret = GNUNET_DISK_file_write (proc->control_pipe, &sig, sizeof(sig)); |
168 | if (ret != sizeof(sig)) | 168 | if (ret != sizeof(sig)) |
169 | { | 169 | { |
170 | if (errno == ECOMM) | 170 | if (errno == ECOMM) |
171 | { | ||
171 | /* Child process is not controllable via pipe */ | 172 | /* Child process is not controllable via pipe */ |
173 | #if DEBUG_OS | ||
172 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 174 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
173 | "Child process is not controllable, will kill it directly\n"); | 175 | "Child process is not controllable, will kill it directly\n"); |
176 | #endif | ||
177 | } | ||
178 | else if (errno == EPIPE) | ||
179 | { | ||
180 | #if DEBUG_OS | ||
181 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
182 | "Failed to write into control pipe, because pipe is invalid (the child is most likely dead)\n"); | ||
183 | #endif | ||
184 | } | ||
174 | else | 185 | else |
175 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 186 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
176 | "Failed to write into control pipe , errno is %d\n", errno); | 187 | "Failed to write into control pipe , errno is %d\n", errno); |
177 | #if WINDOWS && !defined(__CYGWIN__) | 188 | #if WINDOWS && !defined(__CYGWIN__) |
178 | TerminateProcess (proc->handle, 0); | 189 | TerminateProcess (proc->handle, 0); |
@@ -182,8 +193,10 @@ GNUNET_OS_process_kill (struct GNUNET_OS_Process *proc, int sig) | |||
182 | } | 193 | } |
183 | else | 194 | else |
184 | { | 195 | { |
196 | #if DEBUG_OS | ||
185 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 197 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
186 | "Wrote control code into control pipe, now waiting\n"); | 198 | "Wrote control code into control pipe, now waiting\n"); |
199 | #endif | ||
187 | 200 | ||
188 | #if WINDOWS | 201 | #if WINDOWS |
189 | /* Give it 3 seconds to die, then kill it in a nice Windows-specific way */ | 202 | /* Give it 3 seconds to die, then kill it in a nice Windows-specific way */ |
@@ -400,9 +413,11 @@ GNUNET_OS_set_process_priority (struct GNUNET_OS_Process *proc, | |||
400 | } | 413 | } |
401 | } | 414 | } |
402 | #else | 415 | #else |
416 | #if DEBUG_OS | ||
403 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, | 417 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, |
404 | "Priority management not availabe for this platform\n"); | 418 | "Priority management not availabe for this platform\n"); |
405 | #endif | 419 | #endif |
420 | #endif | ||
406 | return GNUNET_OK; | 421 | return GNUNET_OK; |
407 | } | 422 | } |
408 | 423 | ||
@@ -750,9 +765,11 @@ GNUNET_OS_start_process_va (struct GNUNET_DISK_PipeHandle *pipe_stdin, | |||
750 | return NULL; | 765 | return NULL; |
751 | } | 766 | } |
752 | 767 | ||
768 | #if DEBUG_OS | ||
753 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 769 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
754 | "Opened the parent end of the pipe `%s'\n", | 770 | "Opened the parent end of the pipe `%s'\n", |
755 | childpipename); | 771 | childpipename); |
772 | #endif | ||
756 | 773 | ||
757 | GNUNET_asprintf (&our_env[0], "%s=", GNUNET_OS_CONTROL_PIPE); | 774 | GNUNET_asprintf (&our_env[0], "%s=", GNUNET_OS_CONTROL_PIPE); |
758 | GNUNET_asprintf (&our_env[1], "%s", childpipename); | 775 | GNUNET_asprintf (&our_env[1], "%s", childpipename); |
@@ -1090,7 +1107,9 @@ GNUNET_OS_start_process_v (const int *lsocks, | |||
1090 | return NULL; | 1107 | return NULL; |
1091 | } | 1108 | } |
1092 | 1109 | ||
1110 | #if DEBUG_OS | ||
1093 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Opened the parent end of the pipe `%s'\n", childpipename); | 1111 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Opened the parent end of the pipe `%s'\n", childpipename); |
1112 | #endif | ||
1094 | 1113 | ||
1095 | GNUNET_asprintf (&our_env[0], "%s=", GNUNET_OS_CONTROL_PIPE); | 1114 | GNUNET_asprintf (&our_env[0], "%s=", GNUNET_OS_CONTROL_PIPE); |
1096 | GNUNET_asprintf (&our_env[1], "%s", childpipename); | 1115 | GNUNET_asprintf (&our_env[1], "%s", childpipename); |