Re-allocation of tty - QNX 6.1

I have created an executable that releases the terminal control and puts itself in the bg. I have made it to print messages every 2 seconds.

Say, I execute it from a terminal (ttyp3) and then exit. When somebody tries to telnet to the server, this tty (ttyp3 in this case) is re-allocated even before the bg job is over. Hence, the output of the bg process appear on the console (even before logging in to the system).

Attaching the source file for your reference.

This scenario doesn’t exist on Linux because that particular tty is not re-allocated to anybody till the job is over.

The ioctl() you are doing isn’t supported on QNX. You should check the return values from all functions.

If my understanding is correct, then the required things are done by procmgr_daemon(…) and daemon(…) functions.

If I use these functions to run a program as a daemon, is there any way to get the stdout and stderr messages on the console from the daemon program.

Look at procmgr_daemon() doc, specificly, PROCMGR_DAEMON_NODEVNULL flag.

Just FYI, open(device, O_NOCTTY) probably is the POSIX way of doing what you want.

If I specify PROCMGR_DAEMON_NODEVNULL flag in procmgr_daemon(…), then I end up having the same problem as I have mentioned (re-allocation of tty).

My requirement is something like this:

  1. Start a daemon process.
  2. Get the stdout and stderr messages on the console.
  3. Exit the shell and login again.
  4. This time I do not want any messages on the console.

I am able to achieve this on Linux. Can I do it in QNX.