From: ivan Date: Wed, 17 Apr 2002 05:22:04 +0000 (+0000) Subject: pid file foo X-Git-Tag: freeside_1_4_0_pre12~72 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=92a72252a2340b013462d057a178f1681401b31c pid file foo --- diff --git a/fs_passwd/fs_passwdd b/fs_passwd/fs_passwdd index be7539984..3a2bd1d27 100755 --- a/fs_passwd/fs_passwdd +++ b/fs_passwd/fs_passwdd @@ -9,7 +9,8 @@ use strict; use Socket; -my($fs_passwdd_socket)="/usr/local/freeside/fs_passwdd_socket"; +my $fs_passwdd_socket = "/usr/local/freeside/fs_passwdd_socket"; +my $pid_file = "$fs_passwdd_socket.pid" $ENV{'PATH'} ='/usr/local/bin:/usr/bin:/usr/ucb:/bin'; $ENV{'SHELL'} = '/bin/sh'; @@ -28,6 +29,16 @@ unlink($fs_passwdd_socket); bind(Server, $uaddr) or die "bind: $!"; listen(Server,SOMAXCONN) or die "listen: $!"; +if ( -e $pid_file ) { + open(PIDFILE,"<$pid_file"); + chomp( my $old_pid = <$pid_file> ); + close PIDFILE; + kill 'TERM', $pid_file; +} +open(PIDFILE,">$pid_file"); +print PIDFILE "$$\n"; +close PIDFILE; + my($paddr); for ( ; $paddr = accept(Client,Server); close Client) { my($me,$old_password,$new_password,$new_gecos,$new_shell);