home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.linux
- Path: sparky!uunet!munnari.oz.au!metro!extro.ucc.su.OZ.AU!arumble
- From: arumble@extro.ucc.su.OZ.AU (Anthony Rumble)
- Subject: Re: Seyon, PATCH FOR SEYON1.0
- Message-ID: <arumble.722312451@extro.ucc.su.OZ.AU>
- Sender: news@ucc.su.OZ.AU
- Nntp-Posting-Host: extro.ucc.su.oz.au
- Organization: Sydney University Computing Service, Sydney, NSW, Australia
- References: <1992Nov20.161114.20044@cs.tulane.edu>
- Date: Sat, 21 Nov 1992 02:20:51 GMT
- Lines: 391
-
- kranz@cs.tulane.edu (Barry Kranz) writes:
-
- >Although I have been able to compile the X app Seyon, everytime I
- >execute it I get a "killed by signal 11" error, has anyone gotten
- >this to work?
-
- >Any help would be greatly appreciated!
-
- Yes.. While fixing the LOCKFILE stuff, I found a MAJOR
- bug/nasty.. He should be rapped over the knuckles
- for this one..
-
- Basically, he did something like
- lckf[40] = LOCKFILE; (LOCKFILE being "/usr/spool/uucp/LCK.."
-
- Which is illegal.
-
- Here is a patch that fixes that bug and implementes CORRECT
- lock files...
-
- -------- Cut here -------
-
- diff +show-c-function +new-file seyon/Makefile seyon-1.0//Makefile
- *** seyon/Makefile Sat Nov 21 04:15:21 1992
- --- seyon-1.0//Makefile Mon Nov 16 04:44:29 1992
- *************** DEFS = -DHELPFILE=$(HELPFILE)
- *** 43,49 ****
- LIBS = -lXaw -lXmu -lXt -lX11
- OBJS = Seyon.o SeTerm.o xcsubs.o SePort.o \
- xcscrpt.o SeMain.o SeWin.o SeSubs.o SeHelp.o SeSet.o \
- ! SeDial.o SeTrans.o SeMisc.o lockfile.o
- .c.o:; $(CC) $(CFLAGS) -c $<
-
- all:: seyon-cmd seyon
- --- 43,49 ----
- LIBS = -lXaw -lXmu -lXt -lX11
- OBJS = Seyon.o SeTerm.o xcsubs.o SePort.o \
- xcscrpt.o SeMain.o SeWin.o SeSubs.o SeHelp.o SeSet.o \
- ! SeDial.o SeTrans.o SeMisc.o
- .c.o:; $(CC) $(CFLAGS) -c $<
-
- all:: seyon-cmd seyon
- diff +show-c-function +new-file seyon/SePort.c seyon-1.0//SePort.c
- *** seyon/SePort.c Sat Nov 21 14:27:18 1992
- --- seyon-1.0//SePort.c Mon Nov 16 10:14:41 1992
- ***************
- *** 27,33 ****
-
- #include "seyon.h"
- #include "SeDecl.h"
- - #include "lockfile.h"
-
- /*
- The dial() routine uses these two defines.
- --- 27,32 ----
- *************** send_slowly(s)
- *** 427,449 ****
- Simple, eh?
- */
-
-
- lock_tty()
- {
- ! char lckf[40];
- ! int tmp;
- char *modemname;
-
- ! strcpy(lckf, LOCKFILE);
- modemname = strrchr(port, '/');
- strcat(lckf, (modemname ? (modemname+1) : port));
- ! tmp = makelock(lckf);
-
- ! if (tmp)
- ! return 0;
- }
-
- unlock_tty()
- {
- ! rmlocks();
- }
- --- 426,500 ----
- Simple, eh?
- */
-
- + char lckf[40] = LOCKFILE;
- + char ltmp[40] = LTMPFILE;
-
- lock_tty()
- {
- ! int pid, lckpid, lfd;
- ! char pidstr[20];
- ! char lckpidstr[20];
- char *modemname;
- + extern int errno;
-
- ! /*
- ! * Get our PID, and initialize the filename strings.
- ! */
- ! pid = getpid();
- ! sprintf(pidstr, "%d", pid);
- modemname = strrchr(port, '/');
- strcat(lckf, (modemname ? (modemname+1) : port));
- ! strcat(ltmp, pidstr);
-
- ! /*
- ! * Create the LTMP.<pid> file and scribble our PID in it.
- ! */
- ! unlink(ltmp);
- ! if ((lfd = creat(ltmp, 0444)) == -1) {
- ! fprintf(stderr, "Can't creat(2) LTMP file in %s\r\n", LTMPFILE);
- ! return -1;
- ! }
- ! sprintf(pidstr, "%10d\n", pid);
- ! write(lfd, pidstr, 11);
- ! close(lfd);
- !
- ! /*
- ! * Attempt to link directly - if it works, we're done.
- ! */
- ! relink:
- ! if (link(ltmp, lckf) == 0) {
- ! unlink(ltmp);
- ! return 0;
- ! }
- !
- ! /*
- ! * Oh, bother, there's a LCK..* file already; we must
- ! * now expend effort to learn if it's stale or not.
- ! */
- ! if ((lfd = open(lckf, O_RDONLY)) != -1) {
- ! if (read(lfd, lckpidstr, 11) == 11) {
- ! lckpid = atol(lckpidstr);
- ! if (kill(lckpid, 0) == 0) {
- ! fprintf(stderr, "%s locked by process %d.\r\n", port, lckpid);
- ! unlink(ltmp);
- ! return -1;
- ! }
- ! }
- ! }
- !
- ! /*
- ! * The LCK..* file was stale. Remove and retry.
- ! */
- ! if (unlink(lckf)) {
- ! fprintf(stderr, "Can't unlink(2) stale LCK?\r\n");
- ! unlink(ltmp);
- ! return -1;
- ! }
- ! goto relink;
- ! /*NOTREACHED*/
- }
-
- unlock_tty()
- {
- ! unlink(lckf);
- }
- diff +show-c-function +new-file seyon/lockfile.c seyon-1.0//lockfile.c
- *** seyon/lockfile.c Sat Nov 21 04:10:59 1992
- --- seyon-1.0//lockfile.c
- ***************
- *** 1,182 ****
- - /*************************************************************************
- - General UUCP Lock file Code (For NIXMAIL)
- - --------------------------------------------------------------------------
- - Copyright (c) 1992 Anthony Rumble
- - --------------------------------------------------------------------------
- - RCS Info
- -
- - $Header: /home/smilie/emsi/RCS/lockfile.c,v 1.7 1992/10/18 07:57:51 smilie Exp $
- -
- - $Log: lockfile.c,v $
- - * Revision 1.7 1992/10/18 07:57:51 smilie
- - * added rmlock
- - *
- - * Revision 1.6 1992/10/16 08:58:01 smilie
- - * updated for nixmail
- - *
- - * Revision 1.5 1992/10/10 05:58:36 smilie
- - * took out atexit
- - *
- - * Revision 1.4 1992/10/09 13:36:46 smilie
- - * fixed some warnings
- - *
- - * Revision 1.3 1992/10/09 13:05:45 smilie
- - * fixed a bug with the kill return
- - *
- - * Revision 1.2 1992/10/09 12:56:02 smilie
- - * fixed an debug message up
- - *
- - * Revision 1.1 1992/10/09 09:57:26 smilie
- - * Initial revision
- - *
- -
- - *************************************************************************/
- -
- - /* Feature test switches */
- - #define _POSIX_SOURCE 1
- - #define _LOCKFILE_C
- -
- - /* System Headers */
- - #include <stdio.h>
- - #include <stdlib.h>
- - #include <sys/types.h>
- - #include <unistd.h>
- - #include <signal.h>
- - #include <string.h>
- -
- - /* Local Headers */
- - #include "lockfile.h"
- -
- - /* Macros */
- -
- - /* File scope variables */
- -
- - static char lockfile_rcsid[] = "$Id: lockfile.c,v 1.7 1992/10/18 07:57:51 smilie Exp $";
- - #define RCSID lockfile_rcsid
- -
- - /* External variables */
- -
- - char lock[256]; /* Store the current lockfile */
- -
- - /* External Functions */
- -
- - /* Structures and unions */
- -
- - /* Functions */
- -
- - /************************************************************************
- - RMLOCKS
- - -------------------------------------------------------------------------
- - Remove the current UUCP locks
- - *************************************************************************/
- - void rmlocks(void)
- - {
- - (void)unlink(lock);
- - }
- - /************************************************************************
- - RMLOCK
- - -------------------------------------------------------------------------
- - *************************************************************************/
- - void rmlock(char *s)
- - {
- - (void)unlink(s);
- - }
- - /************************************************************************
- - READLOCK
- - -------------------------------------------------------------------------
- - Read the PID from a lockfile, return -1 if there is no
- - valid lockfile
- - *************************************************************************/
- - pid_t readlock(char *name)
- - {
- - pid_t pid;
- - FILE *fh;
- - /**/
- -
- - if ((fh = fopen(name, "rb")) == NULL) /* Open the lockfile */
- - {
- - #ifdef DEBUG
- - fprintf(stderr, "readlock: %s : %s\n", name, strerror(errno));
- - #endif
- - return -1; /* No lockfile exists */
- - }
- -
- - (void)fread(&pid, sizeof(pid), 1, fh); /* Read in PID */
- - (void)fclose(fh);
- - return pid;
- - }
- - /************************************************************************
- - CHECKLOCK
- - -------------------------------------------------------------------------
- - Check the current lock, return TRUE if a valid lock exists
- - return FALSE if there is no valid lock
- -
- - Pass the full path and filename of the lockfile to name
- - *************************************************************************/
- - int checklock(char *name)
- - {
- - pid_t pid; /* PID Variable */
- - /**/
- -
- - pid = readlock(name); /* Read in PID */
- - if (pid == -1)
- - {
- - #ifdef DEBUG
- - (void)fprintf(stderr, "checklock: no valid lockfile exists\n");
- - #endif
- - return FALSE;
- - }
- -
- - if (kill(pid, 0) == -1) /* See if the PID actually exists */
- - {
- - if (errno == ESRCH)
- - {
- - #ifdef DEBUG
- - (void)fprintf(stderr, "checklock: PID '%u' does not exist, removing lockfile\n", pid);
- - #endif
- - (void)unlink(name); /* Remove lock file as there is no such PID */
- - return FALSE;
- - }
- - (void)fprintf(stderr, "checklock: Unknown KILL return '%u'\n", errno);
- - return FALSE;
- - }
- -
- - return TRUE; /* A valid lockfile was found */
- - }
- - /************************************************************************
- - MAKELOCK
- - -------------------------------------------------------------------------
- - Will creat the lockfile 'name' if there is not a valid lockfile
- - under this name.
- - *************************************************************************/
- - int makelock(char *name)
- - {
- - FILE *fh;
- - pid_t pid;
- - /**/
- -
- - if (checklock(name))
- - {
- - (void)fprintf(stderr, "makelock: Error, Valid lock file exists\n");
- - return FALSE;
- - }
- -
- - pid = getpid(); /* Get current PID */
- -
- - if ((fh = fopen(name, "wb")) == NULL)
- - {
- - (void)fprintf(stderr, "Error creating lockfile '%s'\n", name);
- - return FALSE;
- - }
- -
- - (void)fwrite(&pid, sizeof(pid), 1, fh); /* Write PID */
- - (void)fclose(fh);
- - #ifdef DEBUG
- - (void)fprintf(stderr, "makelock: lock made\n");
- - #endif
- - (void)strcpy(lock, name); /* set global lock file */
- - return TRUE;
- - }
- -
- -
- -
- --- 0 ----
- diff +show-c-function +new-file seyon/lockfile.h seyon-1.0//lockfile.h
- *** seyon/lockfile.h Sat Nov 21 04:10:03 1992
- --- seyon-1.0//lockfile.h
- ***************
- *** 1,36 ****
- - /*************************************************************************
- - GENERAL Lockfile header file
- - --------------------------------------------------------------------------
- - Copyright (c) 1992 Anthony Rumble
- - --------------------------------------------------------------------------
- - RCS Info
- -
- - $Header: /home/smilie/emsi/RCS/lockfile.h,v 1.1 1992/10/09 13:19:00 smilie Exp $
- -
- - $Log: lockfile.h,v $
- - * Revision 1.1 1992/10/09 13:19:00 smilie
- - * Initial revision
- - *
- -
- - $Id: lockfile.h,v 1.1 1992/10/09 13:19:00 smilie Exp $
- -
- - *************************************************************************/
- - #ifndef _LOCKFILE_H
- - #define _LOCKFILE_H
- -
- - #include <sys/types.h>
- -
- - extern char lock[256]; /* lock file name */
- -
- - extern void rmlocks(void); /* remove lock file */
- - extern pid_t readlock(char *); /* read a lock file */
- - extern int checklock(char *); /* check a lock file */
- - extern int makelock(char *); /* make a lock file */
- -
- - #ifndef TRUE
- - #define TRUE 1
- - #define FALSE 0
- - #endif
- -
- - #endif
- -
- --- 0 ----
- Common subdirectories: seyon/xcomm_docs and seyon-1.0//xcomm_docs
- --
- Anthony Rumble
- aka SmilieZ
- "Anything is possible.. If there is enuf money in it"
-