Source whereabouts

Conn Copas C.V.Copas at lut.ac.uk
Tue Aug 4 20:07:02 EDT 1992


A while back, a colleague posted a problem with users being able to kill each
others monitors without permission. Consequently, we've started to look at the
workings of <src/display/d.mon/pgms/stop.c>, but have hit a wall, possibly due
to lack of UNIX expertise. A few questions follow, but first, here is the
relevant code :


/* quiet mode returns:   0 - open OK */
/*                      -1 - driver locked */
/*                      -2 - driver not running */
/*                      -3 - can't open fifos */
/*                      -4 - no such monitor */
/*                      -5 - GIS_LOCK undefined in shell environment */
/*                      -6 - couldn't read, write or create lock file */

#define OK       0
#define LOCKED  -1
#define NO_RUN  -2
#define NO_OPEN -3
#define NO_MON  -4
#define NO_KEY  -5
#define LOCK_FAILED -6

stop_mon(name, forced)
    char *name;
{
    char *cur, *G__getenv();
    int unset;

    unset = 0;
    cur = G__getenv("MONITOR");
    if (cur != NULL && strcmp (cur, name) == 0)
	unset = 1;
    G__setenv("MONITOR",name);
    if (forced)
	R_release_driver();
    R__open_quiet();			/* call open_driver in quiet mode */
    switch (R_open_driver())
    {
    case OK:
	    R_kill_driver();
	    /*R_close_driver();*/
	    fprintf(stderr,"Monitor '%s' terminated\n",name);
	    break;
    case NO_RUN:
	    fprintf(stderr,"Error - Monitor '%s' was not running\n",name);
	    break;
    case NO_MON:
	    fprintf(stderr,"Error - No such monitor as '%s'\n",name);
	    break;
    case LOCKED:
	    fprintf(stderr,"Error - Monitor '%s' in use by another user\n",name);
	    break;
    default:
	    fprintf(stderr,"Error - Locking mechanism failed\n");
	    break;
    }
    if (unset)
	G_unsetenv ("MONITOR");
}


1. HP-UX 8.0 has no system call for <switch>. This function looks awfully like
that which is available through the csh interpreter.
Is it defined somewhere in GRASS src? We can't find it.

2. Our programmer's manual, dated I May 92, lists <R_open_driver> and 
<R_close_driver> as library routines, but not <R_open_quiet> or
<R_kill_driver>. Needless to say, we would like to take a hard look at the
latter. Are we even supposed to possess the source somewhere in */lib?

3. Any other suggestions for troubleshooting? The monitor locks file has -1
written to it for running monitors; .gislock has a PID written, as advertised.
The server is a HP-9000. Display systems include SunSparcs and Macs.

Please e-mail replies if not considered of general interest.   

-- 
Loughborough University of Technology          tel : (0509)263171  ext 4164
Computer-Human Interaction Research Centre     fax : (0509)610815      
Leicestershire  LE11 3TU           e-mail - (Janet):C.V.Copas at uk.ac.lut   
G Britain                 (Internet):C.V.Copas%lut.ac.uk at nsfnet-relay.ac.uk




More information about the grass-dev mailing list