Operating System - HP-UX
1833757 Members
2741 Online
110063 Solutions
New Discussion

Compiling deamon gives an error

 
Terry Kummell
Advisor

Compiling deamon gives an error

I am using an example from Richard Stevens book "Unix Network Programming" (attached) to learn something about programming in the HP-UX environment. The compilation fails because TIOCNOTTY is not defined!? I am somewhat new to HP-UX and I am struggling with the C compiler provided with HP-UX 10.20. Thanks for the help!
5 REPLIES 5
Edward Alfert_2
Respected Contributor

Re: Compiling deamon gives an error

the c compiler that comes with the os is only for compiling the kernel..

get gcc or ansi/c compilers (ansi/c is expensive) but you can download gcc for free
"Do what you love and you will never work a day in your life." - Confucius
Santosh Nair_1
Honored Contributor

Re: Compiling deamon gives an error

Try including ioctl.h...this defines TIOCNOTTY.

Hope this helps

-Santosh
Life is what's happening while you're busy making other plans
Terry Kummell
Advisor

Re: Compiling deamon gives an error

Hi Santosh,

Hmmm, The code is as follows:

#ifdef SIGTSTP /* true if BSD system */
...
#include
...
#endif

Then further down in the code, the place where the compiler actually objects:

#ifdef SIGTSTP /* BSD */
if (setpgrp(0, getpid()) == -1 )
err_sys("can't change process group");

if ( (fd = open("/dev/tty", O_RDWR) {
ioctl(fd, TIOCNOTTY, (char *)NULL) /* disc cntrl term */
}
...
#endif

As you can see, the code includes the appropriate header file. However, in the header file, the define for TIOCNOTTY is also ifdef'd as follows:

#ifdef notdef
#define TIOCNOTTY _IO('t', 113) /* void tty association */
#endif /* notdef */

The notdef variable is not defined in this header file and as far as I can tell (grep'd the sub directory) it isn't defined in the /usr/include/sys or /usr/include directories.

I am tempted to take the define statement and simply move it to the daemon code.... That would fix the compiler problem, but only heaven knows what it would break elsewhere!

Thanks for the help

Santosh Nair_1
Honored Contributor

Re: Compiling deamon gives an error

Terry,

I would recommend that you move the #include out of the #ifdef clause rather than moving the #defines. Could you try this out and let me know what happens.
The reason I say this is because it doesn't look like SIGSTP get defined in HPUX. Also the comment mentions that this is set in BSD systems...HPUX is a SYSV derivative.

Hope this helps.

-Santosh
Life is what's happening while you're busy making other plans
Terry Kummell
Advisor

Re: Compiling deamon gives an error

Hi Santosh

The solution you put forward did indeed allow the daemon to compile. However, it appears that what I really need to do is to get a more current edition of Stevens's book.

In the version that I have, he states on page 77: "This field identifies the process group to receive the signals associated with the terminal: SIGINT, SIGQUIT, SIGHUP, SIGIO, SIGTSTP, SIGCONT, and SIGWINCH. The first three signals are common to both 4.3BSD and System V, while the latter four are 4.3BSD-specific."

It appears that SIGTSTP is defined in HP-UX, which as you say is a System V derivitive. I was using the presence of SIGTSTP to indirectly determine that the operating system was a BSD version. I'll need to try something else.

Thanks so much for your assistance!

Regards,

Terry