How to create constantly running process


 
Thread Tools Search this Thread
Top Forums Programming How to create constantly running process
# 1  
Old 08-23-2006
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...
# 2  
Old 08-24-2006
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Command to get exact tomcat process I am running ignoring other java process

Team, I have multiple batchjobs running in VM, if I do ps -ef |grep java or tomcat I am getting multiple process list. How do I get my exact tomcat process running and that is unique? via shell script? (4 Replies)
Discussion started by: Ghanshyam Ratho
4 Replies

2. UNIX for Advanced & Expert Users

Process remians in Running state causing other similar process to sleep and results to system hang

Hi Experts, I am facing one problem here which is one process always stuck in running state which causes the other similar process to sleep state . This causes my system in hanged state. On doing cat /proc/<pid>wchan showing the "__init_begin" in the output. Can you please help me here... (6 Replies)
Discussion started by: naveeng
6 Replies

3. UNIX for Advanced & Expert Users

Process remians in Running state causing other similar process to sleep and results to system hang

Hi Experts, I am facing one problem here which is one process always stuck in running state which causes the other similar process to sleep state . This causes my system in hanged state. On doing cat /proc/<pid>wchan showing the "__init_begin" in the output. Can you please help me here... (1 Reply)
Discussion started by: naveeng
1 Replies

4. BSD

Process remians in Running state causing other similar process to sleep and results to system hang

Hi Experts, I am facing one problem here which is one process always stuck in running state which causes the other similar process to sleep state . This causes my system in hanged state. On doing cat /proc/<pid>wchan showing the "__init_begin" in the output. Can you please help me here... (0 Replies)
Discussion started by: naveeng
0 Replies

5. UNIX for Dummies Questions & Answers

How a process can check if a particular process is running on different machine?

I have process1 running on one machine and generating some log file. Now another process which can be launched on any machine wants to know if process1 is running or not and also in case it is running it wants to stream the logs file generated by process1 on terminal from which process2 is... (2 Replies)
Discussion started by: saurabhnsit2001
2 Replies

6. UNIX for Dummies Questions & Answers

Running different process from current process?

I have been having some trouble trying to get some code working, so I was wondering...what system calls are required to execute a different program from an already running process? (1 Reply)
Discussion started by: Midwest Product
1 Replies

7. Shell Programming and Scripting

Create a html file if a process is running??

Hi All, I need to check for a process, if the process is running then I have to create an HTML file, say A.HTML. If the process is not running then I have to rename the existing html, say A.HTML to B.HTML so that the process which looks for the file A.HTML does not find it? How do I do... (1 Reply)
Discussion started by: Hangman2
1 Replies

8. Shell Programming and Scripting

script to monitor process running on server and posting a mail if any process is dead

Hello all, I would be happy if any one could help me with a shell script that would determine all the processes running on a Unix server and post a mail if any of the process is not running or aborted. Thanks in advance Regards, pradeep kulkarni. :mad: (13 Replies)
Discussion started by: pradeepmacha
13 Replies

9. UNIX for Advanced & Expert Users

how to create a process

Hell Sir, This is chanikya Is there any System call which behaves just like fork but i dont want to return back two times to the calling func. In the following ex iam creating a child process in the called func but the ex prints two times IN MAIN. ex :- calling() { fork(); } main()... (4 Replies)
Discussion started by: chanikya
4 Replies

10. UNIX for Advanced & Expert Users

How to create a dummy process of a process already running?

Hi Everybody, I want to create a shell script named as say "jip" and it is runned. And i want that when i do ps + grep for the process than this jip should be shown as process. Infact there might be process with name jip which is already running. (3 Replies)
Discussion started by: shambhu
3 Replies
Login or Register to Ask a Question