HAM restart Problem

Hi ,

I developed an application/process which get attach to HAM. Now when I slay/kill the process , it should get restarted automatically as ham_action_restart() cond should get call as I have used this method to restart the process it entity dies. Now the problem is : it does not get restarted most of the times and my recovery count not get updated. though it restarted sometimes but rare.
What would be the reason??? how can I overcome this problem??

A good place to start would be to simplify. Create a very simple program and test with it. If HAM is working, then the problem is in your code. If HAM doesn’t work, then you haven’t figured out how to use it properly yet.

I have tried out with a sample application as well.Am following all teh steps mentioned in qnx help.the problema m facing is sometimes it works perfectly for all kinds of processes and at times it doesnt work at all.Any solution?

If you have a very simple application now that fails, you might want to post the source code.

ya , my sample application is Sample1 which is

#include
#include
#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.
I want to know if I m doing something wrong…Please tell me as got stuck.

I tried your program on QNX 6.3.2 using a Quad Intel PIV machine. It worked perfectly every time. So I wouldn’t look for the problem in your program.