Register
It is currently Mon Dec 22, 2014 1:22 am

multiple instances of same process


All times are UTC - 6 hours


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Thu Apr 30, 2009 5:08 am   

Joined: Thu Apr 30, 2009 4:58 am
Posts: 2
Hi everyone,

I am trying to modify the init script of DHCRELAY to recognise more than the standard 2 variables $INTERFACES and $DHCPSERVERS.

I have added $INTERFACES2 and $DHCPSERVERS2 to the config file /etc/sysconfig/dhcrelay which looks like this:

INTERFACES=eth1
DHCPSERVERS=1.1.1.1
INTERFACES2=eth2
DHCPSERVERS2=2.2.2.2

So the idea is to spawn 2 seperate processes with different PIDS but it looks like it is trying to use the same PID (see below bash -x)

1.PID1= $INTERFACES and $DHCPSERVERS
2.PID2= $INTERFACES2 and $DHCPSERVERS2

code (consider I have sourced all variables)

########################################
#Start First DHCP Instance
echo -n $"Starting $prog: "
daemon /usr/sbin/dhcrelay \
$([ -n "$INTERFACES" ] && for int in $INTERFACES ; do echo -n " -i $int" ; done) \
$DHCPSERVERS > /dev/null
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/dhcrelay
return $RETVAL

#Start Second DHCP Instance
echo -n $"Starting $prog: "
daemon /usr/sbin/dhcrelay \
$([ -n "$INTERFACES2" ] && for int in $INTERFACES2 ; do echo -n " -i $int" ; done) \
$DHCPSERVERS2 > /dev/null
RETVAL2=$?
echo
[ $RETVAL2 -eq 0 ] && touch /var/lock/subsys/dhcrelay2
return $RETVAL2
#############################################

DEBUG:

bash -x /etc/rc3.d/S55dhcrelay

Starting dhcrelay: ++ '[' -n 'eth0 eth4' ']'
++ echo -n ' -i eth0'
++ echo -n ' -i eth4'
+ daemon /usr/sbin/dhcrelay -i eth0 -i eth4 1.1.1.2
+ local gotbase= force=
+ local base= user= nice= bg= pid=
+ nicelevel=0
+ '[' /usr/sbin/dhcrelay '!=' /usr/sbin/dhcrelay ']'
+ '[' -z '' ']'
+ base=dhcrelay
+ '[' -f /var/run/dhcrelay.pid ']'
+ local line p
+ read line
+ '[' -z '' -a -d /proc/2878 ']'
+ pid= 2878
+ '[' -n ' 2878' -a -z '' ']'
+ return
+ RETVAL=0
+ echo

+ '[' 0 -eq 0 ']'
+ touch /var/lock/subsys/dhcrelay
+ echo -n 'Starting dhcrelay: '
Starting dhcrelay: ++ '[' -n eth1 ']'
++ echo -n ' -i eth1'
+ daemon /usr/sbin/dhcrelay -i eth1 2.2.2.2
+ local gotbase= force=
+ local base= user= nice= bg= pid=
+ nicelevel=0
+ '[' /usr/sbin/dhcrelay '!=' /usr/sbin/dhcrelay ']'
+ '[' -z '' ']'
+ base=dhcrelay
+ '[' -f /var/run/dhcrelay.pid ']'
+ local line p
+ read line
+ '[' -z '' -a -d /proc/2878 ']'
+ pid= 2878
+ '[' -n ' 2878' -a -z '' ']'
+ return
+ RETVAL2=0
+ echo

+ '[' 0 -eq 0 ']'
+ touch /var/lock/subsys/dhcrelay2
+ return 0


Top
 Profile  
 PostPosted: Thu Apr 30, 2009 7:03 am   

Joined: Thu Apr 30, 2009 4:58 am
Posts: 2
I've got around this by removing the 'daemon' from the script. Any idea what the implications are of doing this.


Top
 Profile  
 PostPosted: Fri May 01, 2009 8:29 am   
Moderator
User avatar

Joined: Thu Oct 11, 2007 7:12 am
Posts: 229
Location: London - UK
Briefly, I note that you don't have an option to set a different pid file for /usr/sbin/dhcrelay
In this case the pid filename is specified by dhcrelay and doesn't seem to be an option you can pass to it, maybe it can be configured in a config file. It _might_ turn out to be a compile option only in which case you'd need 2 versions of dhcrelay installed.

The daemon command will be a function in a script called (or sourced) by the init script. One of the things it does it correctly detatch the spawning process from the parent shell. Where this is depends on your OS but should be easy to find by examining the init script so you can check out what it does.

I don't see a reason why removing the deamon call should solve the issue unless it handles the pid file stuff, which would not be normal from my experience.

I apologize for the lack of detail in this but sadly I don't have time for a more thorough analysis :)


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP