- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- C program Kills cron daemon
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-13-2006 06:36 AM
тАО06-13-2006 06:36 AM
Thanks in advance
-Mike
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-13-2006 06:38 AM
тАО06-13-2006 06:38 AM
Re: C program Kills cron daemon
I would have to see your code to answer the question.
I'm betting though its bad code.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-13-2006 07:00 AM
тАО06-13-2006 07:00 AM
Re: C program Kills cron daemon
Your fundamental error was not immediately doing a setsid() before spawning any child processes so that a new process group is set up. It is then safe to do your kill(0,SIGTERM). The setsid() should occur very early in your cron'ed program. Man setsid for details.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-13-2006 07:44 AM
тАО06-13-2006 07:44 AM
Re: C program Kills cron daemon
The program was called from a start script, executed by the cron, and even though the PPID is now 1 because the script that started it has finished, the program is still tied to the cron? If the cron goes down say 70% of the time the program in question receives an interrupt, why isn't the cron dying the other 30% of the time?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-13-2006 08:06 AM
тАО06-13-2006 08:06 AM
Re: C program Kills cron daemon
The issue appears to be similar to one I resolved year back when we had a security program that attempted to kill lingering child processes. Unfortunately, the PPID was 1, which KILLED every process with a PPID of 1.
cron's ppid is 1
It's your code. You should not kill processes with a PPID = 0 or 1. If a parent dies, the child gets assigned to init, hence ppid=1!
Find a better way to locate and kill the actually related processes.
live free or die
harry d brown jr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-13-2006 08:45 AM
тАО06-13-2006 08:45 AM
Solutionint main(int argc, char *argv[])
int cc = 0;
pid_t pid = 0;
{
pid = fork();
if (pid == 0)
{ /* child process */
setsid();
chdir("/"); /* so that filesystems can umount */
/* Now your real work goes here */
exit(cc);
}
else
{ /* parent process; just exit */
exit(cc);
}
} /* main */
if you fork() and then do the setsid(), you are assurred of setting up a new process group so your kill(0,SIGXXX) will not clobber cron.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-16-2006 04:27 AM
тАО06-16-2006 04:27 AM