Sponsored Content
Top Forums Programming Daemon...Zombie?? Please help me Post 71294 by Perderabo on Monday 9th of May 2005 09:18:53 PM
Old 05-09-2005
Please make sure that you have read our rules. And note:
(6) Do not post classroom or homework problems.

But we sometimes bend this rule when a student has done a lot of work. So I'll make a few comments based on a quick scan of your code. This line of code:
while(1) sleep(1);//run
is dangerous. Why do you have it? I would delete it. If you meant to do something like:
while (1) { List() ; sleep(1) ; }
then you have the fork() in the wrong place. You need to fork() once at the beginning of the program. At present, your program is running List() once and then falling into your infinite sleep loop. You have some re-writing to do.

wait(30);
is illegal and also dangerous. I don't even know what you want to happen there. The last thing you do in List is to ignore some signals. You should ignore signals earlier. If you put List() in a loop, you need to move the signal calls to near the beginning somewhere.

Your instructor probably told you to check if the parent pid is 1, but your instructor is wrong. That is not the definition of a daemon. As it happens, you can probably get away with test you have. But the definition of a daemon is a program with no controlling terminal. You could check that by attempting to open /dev/tty. A daemon must fail but a non-damon must succeed.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

zombie program

When you run a ps -ef and if the status is a Z (zombie) does that mean the same as not responding? (Like a windows machine). Also has anyone here heard of the program called 'top' (I've found it on our Solaris 7 machines) If you have you might be able to help me. I need to know if there is a... (8 Replies)
Discussion started by: merlin
8 Replies

2. UNIX for Advanced & Expert Users

Zombie process

I would like to create a zombie process so that I can test monitoring software functionality. Any techniques? (2 Replies)
Discussion started by: swhitney
2 Replies

3. UNIX for Advanced & Expert Users

zombie daemon process!!

My daemon process is the child of init and init has the responsibility to remove it, once it turns zombie. But I want to ask why the daemon process which is child of init turns zombie in the first place. What measures I have to take to avoid this? rish (1 Reply)
Discussion started by: rish2005
1 Replies

4. Shell Programming and Scripting

Zombie process

Hi I need help because I don't know if it is possible to add a find inside a cat. like I have a file with the pid of the process that use to became zombie. And I have the same pid stored in the var (pid1) now, I have no clue how to check if the the find finds the pid or even if it's... (2 Replies)
Discussion started by: ruben.rodrigues
2 Replies

5. Solaris

zombie process

dear friends, in an interview they asked me what is zombie process. how we can identifying these process.if can you kill all zombie process. (8 Replies)
Discussion started by: sijocg
8 Replies

6. AIX

zombie process

Is there an equivilant to the preap command in AIX that would allow me to get rid of a zombie process. I am new to AIX, moving over from Solaris and in the past I have been able to preap the pid on the defunct process to clean them up. I have looked around and the best I can see is that it may... (3 Replies)
Discussion started by: sboots
3 Replies

7. UNIX for Dummies Questions & Answers

what is zombie , how to kill it ,

Hello I try to googled it , but I dint get sufficient answer :( .. When I can see zombie running on server do they consume system resources or not ? I have read that is not good to kill them with signal 9 cause it might cause more troubles .. why is kill -9 so harmfull? thanks (2 Replies)
Discussion started by: kvok
2 Replies

8. UNIX for Advanced & Expert Users

Zombie process

What is the overhead associated with zombie process?Is it running out of process-ID?:confused: Since some information is stored in process table.. Thanks in Advance (4 Replies)
Discussion started by: jois
4 Replies

9. Red Hat

zombie

Hi, Linux redhat 5.5 top shows that i have 20 zombie process : Tasks: 357 total, 1 running, 336 sleeping, 0 stopped, 20 zombie Cpu(s): 0.2%us, 0.3%sy, 0.0%ni, 99.5%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st Mem: 24949400k total, 2363052k used, 22586348k free, 227084k buffers... (1 Reply)
Discussion started by: yoavbe
1 Replies

10. Programming

Zombie in C

hello all, when we are creating a process by using fork, if the child process terminates before parent, the child process exists as zombie.. My doubt is when that child process terminates, how come that process exists further and show as a zombie process..can anyone help me to clear about this? (1 Reply)
Discussion started by: aarathy
1 Replies
SLEEPD(8)						      System Manager's Manual							 SLEEPD(8)

NAME
sleepd - puts a laptop to sleep during inactivity or on low battery SYNOPSIS
sleepd [-s command] [-d command] [-u n] [-U n] [-I] [-i n] [-E] [-e filename] [-a] [-l n] [-w] [-n] [-v] [-c n] [-b n] [-A] [-H] [-N [device] [-r n] [-t n]] DESCRIPTION
sleepd is a daemon to force laptops to go to sleep after some period of inactivity. This is useful if your laptop does not automatically go to sleep when you aren't using it, and, like me, you often forget to shut it off. It is also capable of suspending a laptop when its bat- tery gets very low. sleepd can detect activity in several ways. The default is to poll both event devices and interrupts to detect when your laptop is in use due to keyboard or mouse activity. It defaults to polling /dev/input/event*. You may specify a list of device files to poll instead, or use options to enable other means of checking for activity (network activity, utmp, or load average). After a configurable amount of time with no activity, sleepd runs a program to put the laptop to sleep. OPTIONS
-h, --help Show summary of options. -n, --nodaemon Don't fork to background; run in forground. -v, --verbose Output status messages. -u, --unused Number of seconds the laptop can remain idle before being put to sleep. Defaults to 600 seconds (10 minutes). Set to 0 to disable any sleeping due to idleness. -U, --ac-unused If set, controls the number of seconds the laptop can remain idle before being put to sleep when running on AC power. If not set, the laptop will not sleep when it's on AC power. -e, --event Adds an event file to the list that is watched. Using this switch disables polling all files in /dev/input/event*. -E, --no-events This switch disables event device polling. -l, --load If set, a load average higher than this number will prevent the computer from sleeping If not set, the computer will ignore the load average. -w If set, sleepd will also check idletime based on utmp. This will prevent the system from sleeping while remote connections are active. It uses the time limit from -u. -i, --irq Adds an irq to the list that is watched. Using this switch disables automatic detection of keyboard and mouse irqs unless -a is specified as well. -I, --no-irq This switch disables interrupt polling. -a, --auto Automatically detect and watch mouse and keyboard irqs. -s, --sleep-command Command to run to put the laptop to sleep. Defaults to "apm -s" for systems with APM and "pm-suspend" for systems with ACPI. -b, --battery If this option is specified, the daemon will put the laptop to sleep if the percentage of battery charge drops below the specified number and the system is off AC power. This is useful for some laptops which don't handle this themselves. It supports using APM, ACPI, and HAL for querying battery status. -d, --hibernate-command A command to run instead of the regular sleep command when the battery is low. This can be useful if you want to make the system go to sleep when it's not active, but suspend to disk if the battery is low. If not set, the sleep command is used. -N, --netdev Monitor a network interface for activity based on packet count. eth0 is the default. This option may be used more than once with different network interfaces. -t, --tx-min Set a baseline transmit raffic rate in packets per second for network monitoring. Requires -N. -r, --rx-min Set a baseline receive traffic rate in packets per second for network monitoring. Requires -N. -A, --and Only go to sleep if all specified conditions are met. For example, only sleep if idle and if the battery is low. -c, --check-period Number of seconds between check on system status. Defaults to 10 seconds, which should be fine generally. -H, --force-hal Force HAL to be used instead of ACPI or other methods to query battery status. SEE ALSO
sleepctl(1) http://kitenet.net/~joey/code/sleepd/ BUGS
Interrupt monitoring cannot always detect keyboard and mouse. If the keyboard or mouse interrupt is shared (as is common with usb devices), other devices on the same interrupt can keep the system awake. Use event device polling instead. AUTHOR
Joey Hess <joey@kitenet.net> SLEEPD(8)
All times are GMT -4. The time now is 06:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy