diff options
Diffstat (limited to 'libjava/include/name-finder.h')
-rw-r--r-- | libjava/include/name-finder.h | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/libjava/include/name-finder.h b/libjava/include/name-finder.h index 46ae20a3293..805725b4b69 100644 --- a/libjava/include/name-finder.h +++ b/libjava/include/name-finder.h @@ -40,12 +40,19 @@ public: ~_Jv_name_finder () { #if defined (HAVE_PIPE) && defined (HAVE_FORK) - close (f_pipe[1]); - fclose (b_pipe_fd); - - int wstat; - // We don't care about errors here. - waitpid (pid, &wstat, 0); + myclose (f_pipe[0]); + myclose (f_pipe[1]); + myclose (b_pipe[0]); + myclose (b_pipe[1]); + if (b_pipe_fd != NULL) + fclose (b_pipe_fd); + + if (pid >= 0) + { + int wstat; + // We don't care about errors here. + waitpid (pid, &wstat, 0); + } #endif } @@ -72,5 +79,13 @@ private: int f_pipe[2], b_pipe[2]; FILE *b_pipe_fd; int error; + + // Close a descriptor only if it has not been closed. + void myclose (int fd) + { + if (fd != -1) + close (fd); + } + #endif }; |