[732] in Zephyr_Bugs

home help back first fref pref prev next nref lref last post

Overwriting zwgc's /tmp/wg.

daemon@ATHENA.MIT.EDU (R. Bernstein)
Fri Dec 15 17:55:05 1995

Date: Fri, 15 Dec 1995 17:54:43 -0500
From: "R. Bernstein" <rocky@drmsr011.drm.pwj.com>
To: bug-zephyr@MIT.EDU
Cc: murali@drmsr011.drm.pwj.com
Reply-To: rocky@drmsr011.drm.pwj.com

Problem:
  If zwgc is run twice, the /tmp/wg.<uid> file gets overwritten. zwctl 
  (without a WGFILE set) will however only have an effect on one of
  these.
  
  If zwgc is running multiple times and one zwgc is killed, /tmp/wg.<uid>
  file is deleted. This is bad in that it can mess up another working
  version. 

Suggested Solution:
  Before overwriting /tmp/wg.<uid> check to see if the file is already
  there. If so, indicate that this would be a problem were zwgc to
  continue. And suggest deleting the /tmp/wg.<uid> file if it
  is for a stale process. Then die.

  More work could be done, such as to check to see if the process is
  stale.

 
Diff:
  The below works for AIX. In time I'll be trying on SunOS and Solaris.

*** zephyr.c.orig	Fri Jul  7 18:00:53 1995
--- zephyr.c	Fri Dec 15 17:27:45 1995
***************
*** 13,18 ****
--- 13,19 ----
   */
  
  #include <sysdep.h>
+ #include <sys/stat.h>
  
  #if (!defined(lint) && !defined(SABER))
  static const char rcsid_zephyr_c[] = "zephyr.c,v 1.7 1995/07/07 22:00:53 ghudson Exp";
***************
*** 138,143 ****
--- 139,145 ----
      char *temp;
      char *exposure;
      FILE *port_file;
+     struct stat *Buffer;
  
      /*
       * Initialize zephyr.  If error, print error message & exit.
***************
*** 151,156 ****
--- 153,167 ----
       */
      temp = get_zwgc_port_number_filename();
      errno = 0;
+     if (stat(temp, Buffer) == 0) {
+       fprintf(stderr, 
+       "zwgc: file %s already exists. You may have another zwgc running.\n",
+ 	      temp);
+       fprintf(stderr, 
+       "zctl may get confused. If zwgc is not running, remove %s.\n",
+ 	      temp);
+       exit(1);
+     }
      port_file = fopen(temp, "w+");
      if (port_file) {
  	fprintf(port_file, "%d\n", port);






home help back first fref pref prev next nref lref last post