![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| script to monitor process running on server and posting a mail if any process is dead | pradeepmacha | Shell Programming and Scripting | 13 | 03-06-2009 07:33 AM |
| how to create a process | chanikya | UNIX for Advanced & Expert Users | 4 | 04-16-2008 08:29 PM |
| How to create a dummy process of a process already running? | shambhu | UNIX for Advanced & Expert Users | 3 | 08-31-2007 11:22 AM |
| Top running process | caprikar | UNIX for Advanced & Expert Users | 1 | 02-17-2004 10:14 AM |
| Running Process | Deepa | High Level Programming | 2 | 05-15-2002 10:46 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
How to create constantly running process
Ther are two process in my program and i want both to constantly running. So i have written the following code. But one of this process which is calling function wsJobCheck() is getting terminated with giving message : Program exited normally. Can any one suggest why this is happing. Code : Code:
#include"listen_to_ms.h"
#include"job_header.h" /*all headers files are included in this header file*/
#include"ws_job_check.h"
extern void callWSJobCheck(int);
int main()
{
/* declaration */
pid_t childpid;
int j=0;
struct passwd *pwd;
/* creating a new child process */
childpid=fork();
if(childpid==0)
{
/* crete processes for listening to WS */
listenToMS();
exit(0);
}
if(signal(SIGALRM,callWSJobCheck)==SIG_ERR)
{
fprintf(stderr, "\nIN MAIN FUNCTION : Error in SIGALRM\n");
}
else
{
alarm(20);
}
return 0;
}
void callWSJobCheck(int signal)
{
wsJobCheck();
alarm(10);
printf("\nIN MAIN FUNCTION : signal : %d",signal);
}
I am working on AIX os. Last edited by blowtorch; 08-23-2006 at 10:27 AM.. Reason: to put in code tags... |
|
||||
|
alarm() does not wait for anything. It schedules a SIGALRM in the future, but doesn't wait -- so your program sets the handler, schedules the alarm for 20 seconds in the future, then merrily continues on it's way to the return(0); and quits before the alarm even happens. See pause() if you want your process to wait for a signal such as an alarm.
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|