The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-23-2006
bhakti bhakti is offline
Registered User
  
 

Join Date: Sep 2005
Posts: 13
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 (permalink)  
Old 08-24-2006
Corona688 Corona688 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 1,972
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.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:33 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0