Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

daemoniseing results in a Segmentation Foult, by access the GPIB driver

I want to run my program as a daemon under SUSE Linux 9.2 (NI driver 2.3). But when I demonize the process the fist driver function call results in a segmentation fault. I post a part of the source to show you what I do:

 

if(pid != 0)

   exit(EXIT_SUCCESS);

setsid();

signal(SIGHUP,SIG_IGN);

 

if(fork != 0)

   exit(EXIT_SUCCESS);

chdir(“/”);

 

unmask(0);

 

for(i = sysconf(_SC_OPEN_MAX); i > 0; I --)

close(i);

 

/****************************

**** some other code ****

****************************/

 

 

SendIFC(0); /***segmentation fault***/
 
 
 
Greets
A. Schäfer
0 Kudos
Message 1 of 5
(3,668 Views)
I noticed that you had a fork variable in your code. We have noticed that forks don't always play nice with our NI drivers. Try taking out the forks and see if that helps.

-Josh
0 Kudos
Message 2 of 5
(3,656 Views)
But I need the forks for daemonize the prozess, or there is another way to daemonize it?
0 Kudos
Message 3 of 5
(3,648 Views)
All I can say is that is a current known issue. We are trying to come up with some kind of work around, but we don't have anything yet. If you perform all of your forks before ever loading or using the NI driver it might work.

-Joshua Prewitt
Linux PSE
0 Kudos
Message 4 of 5
(3,638 Views)
I had a similiar problem on a new Ubuntu system (kernel 2.6.15).  Even without making any calls to any NI488 functions, the fork would not work.  Just having the API library loaded in caused the child process to fail.

If you remove the fork system call, and just invoke your process in the background with the '&' option, you should have what you want.  Eg. 'mydaemon &' will run it in the background, and you will have your daemon.

NI has been pretty good about supporting the linux GPIB driver.  Hopefully this problem will be fixed soon.
0 Kudos
Message 5 of 5
(3,537 Views)