Soumik Mondal
10/06/2009 5:59 AM
post39423
|
I have created one Sample Application as Sample1
source code is :
#include <cstdlib>
#include <iostream>
#include <stdio.h>
#include <unistd.h>
#include <sys/procmgr.h>
int main(int argc, char *argv[])
{
procmgr_daemon( EXIT_SUCCESS, 0x000000FF );
sleep(20);
printf("Welcome to the QNX Momentics IDE\n");
sleep(20);
return EXIT_SUCCESS;
}
Now I have devoloped a new project called Test1 in which I attached Sample1 with HAM as
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/netmgr.h>
#include <fcntl.h>
#include "ha/ham.h"
int main(int argc, char *argv[])
{
int status;
char *inetdpath;
ham_entity_t *ehdl;
ham_condition_t *chdl;
ham_action_t *ahdl;
int inetdpid;
if (argc > 1)
inetdpath = strdup(argv[1]);
else
inetdpath = strdup("/root/HAM_Test/Sample1");
if (argc > 2)
inetdpid = atoi(argv[2]);
else
inetdpid = -1;
ham_connect(0);
ehdl = ham_attach("Sample1", ND_LOCAL_NODE, inetdpid, inetdpath, 0);
if (ehdl != NULL)
{
chdl = ham_condition(ehdl,CONDDEATH, "death", HREARMAFTERRESTART);
//start if
if (chdl != NULL)
{
ahdl = ham_action_restart(chdl, "restart", inetdpath,
HREARMAFTERRESTART);
if (ahdl == NULL)
printf("add action failed\n");
}//end if
else
printf("add condition failed\n");
}
else
printf("add entity failed\n");
ham_disconnect(0);
exit(0);
}
Now The Sample1 get attached to test1....
I verified this by
ls -al /proc/ham
and cat /proc/ham/Sample1/.info
now when I slay Sample1
It sometimes get restarted by itself , Sometimes not....means if after slaying Sample1 when I do #cat /proc/ham/Sample1/
.info
value od restart is 0 though it gets restarted sometimes and increment the counter to 1, 2 and so-on when I slay the
application Sample1
It is showing same behaviour with inetd , mq ......So it is showing very unexpected behaviour
Is should restart the process everytime if ham is running properly or don't increment at all if not working properly....
I have stuck here and tried everything
Please suggest any solution.
I want to know if I m doing something wrong....Please tell me as got stuck.
|
|
|