tignore host read eof while exiting - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit f0264abf2684f96c011ad56b292378a67074c148
 (DIR) parent 303cb7c6dbb49fd57cb97af77f93fab620eee8d7
 (HTM) Author: rsc <devnull@localhost>
       Date:   Thu, 20 Jan 2005 22:59:50 +0000
       
       ignore host read eof while exiting
       
       Diffstat:
         M src/cmd/samterm/mesg.c              |       3 +++
         M src/cmd/samterm/plan9.c             |       5 +++++
         M src/cmd/samterm/samterm.h           |       1 +
       
       3 files changed, 9 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/src/cmd/samterm/mesg.c b/src/cmd/samterm/mesg.c
       t@@ -17,6 +17,7 @@ uchar        outdata[DATASIZE];
        short        outcount;
        int        hversion;
        int        hostfd[2];
       +int        exiting;
        
        void        inmesg(Hmesg, int);
        int        inshort(int);
       t@@ -29,6 +30,7 @@ void        hplumb(int);
        void        clrlock(void);
        int        snarfswap(char*, int, char**);
        
       +
        void
        rcv(void)
        {
       t@@ -298,6 +300,7 @@ inmesg(Hmesg type, int count)
                        break;
        
                case Hexit:
       +                exiting = 1;
                        outT0(Texit);
                        threadexitsall(nil);
                        break;
 (DIR) diff --git a/src/cmd/samterm/plan9.c b/src/cmd/samterm/plan9.c
       t@@ -279,6 +279,11 @@ hostproc(void *arg)
                        n = read(hostfd[0], hostbuf[i].data, sizeof hostbuf[i].data);
        if(0) fprint(2, "hostproc %d\n", n);
                        if(n <= 0){
       +                        if(n == 0){
       +                                if(exiting)
       +                                        threadexits(nil);
       +                                werrstr("unexpected eof");
       +                        }
                                fprint(2, "samterm: host read error: %r\n");
                                threadexitsall("host");
                        }
 (DIR) diff --git a/src/cmd/samterm/samterm.h b/src/cmd/samterm/samterm.h
       t@@ -87,6 +87,7 @@ extern Channel *hostc;
        extern int        hversion;
        extern int        plumbfd;
        extern int        hostfd[2];
       +extern int        exiting;
        
        #define gettext sam_gettext        /* stupid gcc built-in functions */
        Rune        *gettext(Flayer*, long, ulong*);