Opened 8 years ago

Closed 8 months ago

#11797 closed bug (fixed)

Calling getpid() from constructor of global static object returns 0

Reported by: tokoe Owned by: nobody
Priority: normal Milestone: R1/beta4
Component: System/POSIX Version: R1/Development
Keywords: Cc:
Blocked By: Blocking: #17723
Platform: x86

Description

If you call getpid() from within the constructor of a custom class and create a global static object of that class, getpid() returns 0 instead of the process ID. Calling getpid() from inside main() function or any scope that is entered later on, works fine.

Attachments (1)

main.cpp (289 bytes ) - added by tokoe 8 years ago.
test case that demonstrate the problem

Download all attachments as: .zip

Change History (7)

by tokoe, 8 years ago

Attachment: main.cpp added

test case that demonstrate the problem

comment:1 by korli, 8 years ago

This ID is local and initialized by the function calling the main(), after global constructors. Caching this ID is probably a "bad idea" anyway.

comment:3 by tokoe, 8 years ago

So is there a chance to fix that behavior (because on other Unix/POSIX systems like Linux, FreeBSD or MacOSX it works), or are there any technical limitations in the process handling/C runtime of Haiku?

comment:4 by korli, 9 months ago

Blocking: 17723 added

comment:6 by pulkomandy, 8 months ago

Milestone: R1R1/beta4
Resolution: fixed
Status: newclosed

Patch applied in hrev56203.

Note: See TracTickets for help on using tickets.