uugetty & lock files

Randy Davis root at ninja.dell.com
Sat Sep 8 02:22:37 AEST 1990


In article <384 at fe2o3.UUCP> michael at fe2o3.UUCP (Michael Katzmann) writes:
|The problem:
|	uugetty seems to create a lockfile when a character is first received.
|I dont know when it is removed (perhaps after uugetty is restarted after a 
|login), however if it was just noise and no login is successful the lockfile,
|it seems, is never removed.

  However, the new login process started after the uugetty times out (you *do*
have the timeout in effect, right?) will have a different process ID number
which should invalidate the process ID number stored in the lockfile, despite
its existance.

|Thus the auto-answer enable programme will not enable the modem and because
|no successful login will take place if the phone is not auto-answered the
|lock file will not be removed.
|
|Any ideas anyone?

   Yeah, easy....  First make sure the uugetty timeout is enabled, then, in
your progam, simply get the process ID number FROM the lockfile and check to
see if the process exists.  If the process does not exist, then remove the
lockfile, since it is invalid.

An easy way to do this is 

if ps -p `cat -s $LCKFILE` > /dev/null
then
  : # don't remove lockfile
 else
  rm $LCKFILE
fi

   For that matter, make sure that you are putting an active process ID in
the lockfile, or the uucico, etc.. processes will remove your lockfile if they
sense that the lockfile is invalid.  The format of the process ID in the file
is special.  Here is a section of shell script that will show you what I mean:

# Contents of the LCK file must be 11 characters in the following format:
# leading spaces, process ID, newline (\n), null (\0).
# E.g.: "    12345\n\0"
#        1234567891011
# The following takes care of the space padding...
PID=$$
# PID in the range of single digits up to 30000 (5 digits)
if [ "$PID" -lt "10000" ]
then
  PID=" $PID"
  if [ "$PID" -lt "1000" ]
  then
    PID=" $PID"
    if [ "$PID" -lt "100" ]
     then
      PID=" $PID"
      if [ "$PID" -lt "10" ]
       then
        PID=" $PID"
      fi
    fi
  fi
fi
PID="    $PID"

echo "${PID}\n\0\c" > ${LCKFILE}
/bin/chown uucp ${LCKFILE}
/bin/chgrp uucp ${LCKFILE}
/bin/chmod 444 ${LCKFILE}


  Hopefully this is correct.  I use to work with HDB uucp ALL the time, then
I got into networked systems and haven't touched it in almost a year.

Good luck,

Randy Davis					UUCP: rjd at ninja.dell.com

-- 



More information about the Comp.unix.questions mailing list