“Keith Vasilakes” <kvasilak@cyberoptics.com> wrote in message
news:3C98A0F2.4984B639@cyberoptics.com…
Newbie here…
I am trying to accomplish the same thing, how do I ignore this SIGHUP
signal?
The only way I see is by starting the process with qnx_Spawn()?
Keith
Chris Nasr wrote:
Richard,
thanks, I trapped SIGHUP and that fixed my problem. Much appreciated.
Chris
“Brown, Richard” wrote:
Additionally you can:
- become a daemon process by:
- fork(), terminate parent, child continues
- setsid() in the child
- ignore SIGHUP
- fork(), terminate parent, child continues
- close all open descriptors
- log errors to your own log file or use syslogd
- ignore SIGHUP signals and start it in the background using &
“Ken Schumm” <> kwschumm@IH8SPAMqsolv.com> > wrote in message
news:Voyager.020204152200.15126A@dilbert…
Previously, Chris Nasr wrote in qdn.public.qnx4:
Hi,
I’m having a problem that I’m sure is easy, I just can’t figure
out how
to find the answer in the help.
I have a program that needs to run in the background, and I need
to be
able to run it from a shell then close the shell without the
program
dying. I know this is possible because I’ve seen it before, I’m
just not
sure how to make it happen, can anyone point me in the right
direction?
Thanks in advance,
Look at the nohup command.
\
Chris Nasr
cnasr[at]mechtronix[dot]ca
Mechtronix Systems Inc.
#include <sys/types.h
#include <sys/stat.h>
#include <fcntl.h>
#include <stddef.h>
#include <process.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
void main
(
int argc,
char *argv
)
{
char fname[32]; // gets filename from argv 0
if (argc != 2)
{
printf(“detach progpath\n”);
exit(1);
}
if (fork())
exit(0);
close(0);
close(1);
close(2);
open(“/dev/con1”, O_RDONLY);
open(“/home/manila/detach.log”, O_WRONLY | O_CREAT | O_APPEND);
open(“/home/manila/detach.log”, O_WRONLY | O_CREAT | O_APPEND);
if (-1 == setsid())
{
perror(“Couldn’t setsid”);
exit(1);
}
_splitpath(argv[1],
0, // node
0, // dir
fname, // filename
0); // extension
execl(argv[1], fname, 0);
perror(“Couldn’t exec”);
exit(1);
}