1760078 Members
2370 Online
108889 Solutions
New Discussion юеВ

Re: Function getpid

 
MmC_3
Occasional Advisor

Function getpid

Hi, on HP-UX 10.20 I was using the function getpid. Since we upgrade to HP-UX 11.11, I can't compile anymore and I kept exactly the same include.

Anybody aware of a change about the getpid function ?
regards,
Marco
6 REPLIES 6
Hein van den Heuvel
Honored Contributor

Re: Function getpid

First let me assure you this will be something specific to your environment.

getpid is an essential system service, used by _everything_.
It it there, it works.

" I can't compile anymore "

Please qualify / quantify.
What is stoppping you from compiling?

Did you forget how?
Are you getting an error?

Some programs? All programs?
Which error? (Please cut&paste, details may matter)
I guess it complains about getpid... exactly what message?

Take a babystep...
Create and compile the following 'program'

----- test.c -------------
#include
#include
main () {
pid_t pid, ppid;
pid = getpid();
ppid = getppid();
printf ("Parent = %d, Pid = %d\n", ppid, pid);
}
--------------------
# cc test.c
# ./a.out
Parent = 16024, Pid = 16433
# ps
PID TTY TIME COMMAND
16479 pts/tg 0:00 ps
16024 pts/tg 0:00 sh


Does that work for you?
If so, you can compile, and getpid does work!

Hope this helps to get you going,
Hein.

MmC_3
Occasional Advisor

Re: Function getpid

Hi Hein,
great answer but the only line needed was #include .
thanks.
MmC_3
Occasional Advisor

Re: Function getpid

Include was missing
Steven Schweda
Honored Contributor

Re: Function getpid

> great answer but the only line needed was
> #include .

Hein: Well, duh. If your psychic powers
were good for anything, you'd've know that,
and you could've saved us all a lot of time.
Be smarter next time, will you?


MmC: Next time, try "man getpid":

[...]
SYNOPSIS
#include
[...]
Dennis Handly
Acclaimed Contributor

Re: Function getpid

>Steven: Hein: If your psychic powers were good for anything, ...

I'm at a loss to explain why this would fail since getpid(2) returns pid_t which is the default (int) and has a void parm.

>Next time, try "man getpid":

Exactly. Or use compiler options that make missing prototypes an error.

In fact if you try to call malloc in 64 bit, the aCC6 compiler will give an error if a prototype is missing.
Steven Schweda
Honored Contributor

Re: Function getpid

> I'm at a loss to explain why this would
> fail [...]

You appear to assume that "I can't compile"
implies an actual failure to compile. With
evidence this sparse, that entails some risk.
Or, as Mr. Sumner advised Bunny in "Desk
Set", "Never assume."