Mercurial > hg > octave-nkf
diff src/oct-procbuf.cc @ 3644:9add655e8b8c
[project @ 2000-03-24 11:58:50 by jwe]
author | jwe |
---|---|
date | Fri, 24 Mar 2000 11:58:50 +0000 |
parents | 95d7c4b2b2e8 |
children | 3a067b216fd6 |
line wrap: on
line diff
--- a/src/oct-procbuf.cc +++ b/src/oct-procbuf.cc @@ -99,7 +99,14 @@ while (octave_procbuf_list) { - ::fclose (octave_procbuf_list->f); + FILE *fp = octave_procbuf_list->f; + + if (fp) + { + ::fclose (fp); + fp = 0; + } + octave_procbuf_list = octave_procbuf_list->next; } @@ -140,31 +147,36 @@ { #if defined (HAVE_SYS_WAIT_H) - pid_t wait_pid; - - int status = -1; + if (f) + { + pid_t wait_pid; - for (octave_procbuf **ptr = &octave_procbuf_list; - *ptr != 0; - ptr = &(*ptr)->next) - { - if (*ptr == this) + int status = -1; + + for (octave_procbuf **ptr = &octave_procbuf_list; + *ptr != 0; + ptr = &(*ptr)->next) { - *ptr = (*ptr)->next; - status = 0; - break; + if (*ptr == this) + { + *ptr = (*ptr)->next; + status = 0; + break; + } } - } - if (status == 0 && ::fclose (f) == 0) - { - using namespace std; + if (status == 0 && ::fclose (f) == 0) + { + using namespace std; - do - { - wait_pid = ::waitpid (proc_pid, &wstatus, 0); + do + { + wait_pid = ::waitpid (proc_pid, &wstatus, 0); + } + while (wait_pid == -1 && errno == EINTR); } - while (wait_pid == -1 && errno == EINTR); + + f = 0; } open_p = false;