Mercurial > octave-nkf
diff src/oct-procbuf.cc @ 3631:0b6b55fd0a5c
[project @ 2000-03-23 09:16:36 by jwe]
author | jwe |
---|---|
date | Thu, 23 Mar 2000 09:16:37 +0000 |
parents | 71bd2d124119 |
children | 95d7c4b2b2e8 |
line wrap: on
line diff
--- a/src/oct-procbuf.cc Thu Mar 23 07:42:55 2000 +0000 +++ b/src/oct-procbuf.cc Thu Mar 23 09:16:37 2000 +0000 @@ -54,11 +54,6 @@ // This class is based on the procbuf class from libg++, written by // Per Bothner, Copyright (C) 1993 Free Software Foundation. -// -// It should work with the filebuf class from libg++, but it might not -// work with others since it depends on being able to get at the -// underlying file descriptor with filebuf::fd(), which is not -// standard. static octave_procbuf *octave_procbuf_list = 0; @@ -104,7 +99,7 @@ while (octave_procbuf_list) { - ::close (octave_procbuf_list->fd ()); + ::fclose (octave_procbuf_list->f); octave_procbuf_list = octave_procbuf_list->next; } @@ -124,7 +119,9 @@ return 0; } - attach (parent_end); + f = ::fdopen (parent_end, (mode & std::ios::in) ? "w" : "r"); + + open_p = true; next = octave_procbuf_list; octave_procbuf_list = this; @@ -138,8 +135,8 @@ #endif } -int -octave_procbuf::sys_close (void) +octave_procbuf * +octave_procbuf::close (void) { #if defined (HAVE_SYS_WAIT_H) @@ -159,27 +156,24 @@ } } - if (status < 0 || ::close (fd ()) < 0) - return -1; - - { - using namespace std; + if (status == 0 && ::fclose (f) == 0) + { + using namespace std; - do - { - wait_pid = ::waitpid (proc_pid, &wstatus, 0); - } - while (wait_pid == -1 && errno == EINTR); - } + do + { + wait_pid = ::waitpid (proc_pid, &wstatus, 0); + } + while (wait_pid == -1 && errno == EINTR); + } - if (wait_pid == -1) - return -1; + open_p = false; - return wstatus; + return this; #else - return -1; + return 0; #endif }