Annotation of researchv9/cmd/adb/null/dump, revision 1.1.1.1

1.1       root        1: From research!cithep!sickkids!mark Thu Nov  7 15:24 EST 1985
                      2: I need to make a couple minor changes to dump, and having looked through
                      3: the code I've been reminded of just how sleazy it is.  I've already told
                      4: you about how it uses 1 rather than 0 as its normal exit status, thus
                      5: ignoring all the standard unix conventions regarding such things.  Now
                      6: I found another goodie.  There's an option which permits messages to be
                      7: broadcast to all logged in users whom the program deems to be operators.
                      8: The broadcasting is done by a subprocess.  (Never mind why; that's another
                      9: story.)  What you may be amused and/or disgusted by is the following code
                     10: fragment ...
                     11: 
                     12:        switch (pid = fork()) {
                     13:        case -1:
                     14:                return;
                     15:        case 0:
                     16:                break;
                     17:        default:
                     18:                while (wait(&s) != pid)
                     19:                        continue;
                     20:                return;
                     21:        }
                     22: 
                     23:        if (!notify || gp == 0)
                     24:                exit(0);
                     25: 
                     26: Given that the default is notify==0, think of all those poor processes,
                     27: spawned only to die an immediate death!
                     28: 
                     29: But wait -- there's more!  It goes on to do its thing.  When it finishes
                     30: up, it does ...
                     31: 
                     32:        Exit(0);        /* the wait in this same routine will catch this */
                     33: 
                     34: ... which is correct, provided you think it makes sense to do all this in a
                     35: subprocess.  However, before getting to this point, one finds the following:
                     36: 
                     37:        if((f_utmp = fopen("/etc/utmp", "r")) == NULL) {
                     38:                msg("Cannot open /etc/utmp\n");
                     39:                return;
                     40:        }
                     41: 
                     42: Yes, "return", not "exit"!  Who wrote this mess, anyway?  It seems worse
                     43: than even my wildest nightmare of the possible product of a Joy/Horton
                     44: collaboration.
                     45: 
                     46: 
                     47: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.