QNX RTOS v4 Knowledge Base
QNX RTOS v4 Knowledge Base
Title |
How can I ensure that users are running my application as a background task on QNX4? |
Ref. No. |
QNX.000009328 |
Category(ies) |
Utilities, Development, Configuration |
Issue |
My program needs to be started in the background (i.e. myprog &). How can I ensure that the user runs it as a background task on QNX 4?
|
Solution |
One way to verify that a task has been run as a background task is to see if the interactive attention signal is active or not. This is the signal that allows a user to press CTRL-C to exit a program, and when a progam is run in the background this signal is disabled for that program. Here's a sample piece of code that checks to see how the program was started:
#include <stdio.h> #include <signal.h>
void main ( int argc, chat **argv ) { if ( signal ( SIGINT, SIG_IGN ) != SIG-IGN ) x09printf("Not in background.n"); // insert a help-style message here // ie. Program must be started in background else x09printf("In background.n"); // insert rest of program here. }
|
|