mkitab problem with /etc/inittab respawning


 
Thread Tools Search this Thread
Operating Systems AIX mkitab problem with /etc/inittab respawning
# 15  
Old 09-25-2008
I wonder if this has something to do with the fact that the dprdaemon program runs in the background (using 'fork').

I have found this page:

FGA: Mistakes to avoid when designing Unix dmon programs

Which seems to indicate that the 'fork' should be taken out of the daemon script.

Here is part of the daemon script, which I got off the 'Net:


## Define functions
sub daemonize {
chdir '/' or die "Can't chdir to /: $!";
open STDIN, '/dev/null' or die "Can't read /dev/null: $!";
open STDOUT, '>>/dev/null' or die "Can't write to /dev/null: $!";
open STDERR, '>>/dev/null' or die "Can't write to /dev/null: $!";
defined (my $pid = fork) or die "Can't fork: $!";
exit if $pid;
setsid or die "Can't start a new session: $!";
umask 0;
}


## The following executable called by dpr_daemon
sub monitor_logfiles {
`/dplogs/dpr/dpr_monitor`;
}


## initialize Perl
$[ = 1; # set array base to 1
$| = 1; # flush the buffer


## prepare dpr_daemon
daemonize();


## summon dpr_daemon
while(1) {
monitor_logfiles;

#wait for 20 seconds
sleep(20);
}


The article suggests that yes this would work if run off the command line, but I think it is saying that if it is called by SRC, then it will automatically run in the background and therefore fork isn't necessary.

Hmmmm
# 16  
Old 09-25-2008
That is a good link. Please reread this sentence: "The concepts of "foreground" and "background" don't apply to dæmons." a few times. There is no such thing as a daemon running in the "background". Foreground and background only apply to programs with a controlling terminal. By definition, a daemon has no controlling terminal. Yes you seem to have a daemon that is superfluously re-daemonizing itself, but if done correctly this is a harmless waste of time. I doubt that it explains 3 instances of the daemon running. Still, why not remove that code and see what happens? A program launched by "cron" or "at" will be a daemon and this might be an easier way to test it.
# 17  
Old 09-25-2008
Yes all that is well and good and I agree. I was the one who proposed cron in the first place. But this company wants something that runs 'continuously'.
I won a compromise by creating a daemon that issues every 20 seconds (once a minute was not good enough).

As far as taking the fork out of the beast, I am tempted to remove this line and simply re-run everything:

defined (my $pid = fork) or die "Can't fork: $!";
exit if $pid;

The article doesn't seem to say exactly what to take out.
However my instincts for job self-preservation have dictated that I should chew my nails and build up some courage for awhile, check the web and perhaps wait for a forum reply before attempting it. Especially since I have nothing but a root login to use and am not permitted to create a regular account without clearance.

Nothing would please this crew more than to string me up by the neck for inadvertently creating runaway processes or some mistake that caused a bottleneck on the box. Not much room for trial and error.
Did I mention I love my job?

I do!
# 18  
Old 09-25-2008
ALLLLRIGHT..........

I got bold and commented out these lines in the daemon script:

##defined (my $pid = fork) or die "Can't fork: $!";
##exit if $pid;
##setsid or die "Can't start a new session: $!";


Then I recreated the SRC trigger, started the resource and there is now only one instance of the daemon running.
The SRC "dprdaemon" also now shows as 'active'.

When I kill the dprdaemon process, it automatically restarts.

And, the program appears to be working also.

I think we have a solution here.............
Smilie knock on wood
# 19  
Old 09-25-2008
The SRC seems to get the impression that your subsystem terminates abnormally. As you defined it to respawn in such a case it will respawn twice within the waittime timelimit. Hence the three processes. So handling of your program/daemon by SRC seems to work as designed. Probably the answer lies in the perl code. Can you activate some debuging mode in your code to trace what happens during start?
# 20  
Old 09-25-2008
Quote:
Originally Posted by jeffpas
[...]

I got bold and commented out these lines in the daemon script:

##defined (my $pid = fork) or die "Can't fork: $!";
##exit if $pid;
##setsid or die "Can't start a new session: $!";


Then I recreated the SRC trigger, started the resource and there is now only one instance of the daemon running.
The SRC "dprdaemon" also now shows as 'active'.

When I kill the dprdaemon process, it automatically restarts.

And, the program appears to be working also.

I think we have a solution here.............
Smilie knock on wood
Congratulations ;-)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script calling by inittab

Hi to all , i wrote a small script and i add it to inittab to start the script during Startup. The script works fine , if i call it from the prompt but if it is call from inittab it is runnng too but it does not recognize system variable like USER , LOGNAME. Since i running out of ideas i... (12 Replies)
Discussion started by: Nadielosabra
12 Replies

2. UNIX for Dummies Questions & Answers

Inittab configuration

I am installing BusyBox on a device that does not have keyboard or serial connection, so I log into the system with SSH. I am in doubt about what to put in the inittab file. This is the content of the file: ::sysinit:/etc/init.d/rcS ::respawn:/bin/login ::shutdown:/sbin/swapoff -a... (1 Reply)
Discussion started by: richard78
1 Replies

3. AIX

problem to restart services from /etc/inittab in AIX6.1

hello, i have an AIX6.1.7.2 machine that it was upgraded recently from AIX5.3.9.4. when i kill system services that should restart automatically like /usr/sbin/cron it doesnt start. i checked my /etc/inittab file and i confirmed that this service is in respawn status so when i kill this process... (2 Replies)
Discussion started by: omonoiatis9
2 Replies

4. UNIX for Dummies Questions & Answers

What breaks inittab

Today there was a situation where processes running from inittab was broken. Can someone help me understand, how to find out, who might have stopped those processes? Or how does it get broken? G (2 Replies)
Discussion started by: ggayathri
2 Replies

5. Solaris

inittab entry does not works

Hi, I have a solaris 10 server,which has a process running that communicates with other system.I have made following entry in the inittab file. PM15:s12345:respawn:/ncm/bin/communicator PM15 : Unique process ID s12345 : run levels respawn : if anytime the process... (2 Replies)
Discussion started by: asalman.qazi
2 Replies

6. Solaris

inittab in Solaris 10

Hi, In Solaris 9 and below release we are using the rc script in inittab. I don't have much idea abt inittab in Solaris. In Solris 9 and below: We use rc3 script to start up the server. And we run database script before the rc3. os:23:respawn:/etc/init.d/database start >/dev/null 2>&1... (7 Replies)
Discussion started by: kalpeer
7 Replies

7. HP-UX

INIT: Command respawning too rapidly

INIT:Command is respawning too rapidly Check for errors: id:cons /usr/sbin/getty console console A solution I read about in a different HPUX Forums help pages on line, said to add the -h option to this command in the /etc/inittab file to correct the problem. I tried this and it did not... (2 Replies)
Discussion started by: 1bigdog
2 Replies

8. UNIX for Dummies Questions & Answers

HP-UX respawning boot failure

Hello. System is a HP Visualize C3600 running X11 and after a power failure machine will not boot (see error messages below) From what I've read, this may be caused by a corrupted etc/inittab file. Solution suggested on other websites is to boot in single user mode and edit file inittab... (2 Replies)
Discussion started by: westcoast
2 Replies

9. UNIX for Dummies Questions & Answers

Command is respawning too rapidly..message

Ran into a new one today at work...... I was told to start 2 servers which were shut down due to a power outage(I don't believe they were shut down incorrectly). After fsck, both console logins appear with the message: INIT: Command is respawning too rapidly. Check for possible errors. >... (5 Replies)
Discussion started by: finster
5 Replies

10. UNIX for Dummies Questions & Answers

inittab solaris

Hi! Is it possible to add more ttys in Solaris, like with inittab in Linux? I want to switch between the ttys with Alt F1+F2+F3 .... like Linux does. How can i do this? (1 Reply)
Discussion started by: donald1111
1 Replies
Login or Register to Ask a Question