This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: g++ running async???


moze wrote:
Hi,

I have a weired phenomena, I want to discuss before filing a bug report.
Sorry, source+data is too big for posting.

I have a Programm(in C++) that calls "g++" to compile a number of cpp-files
and afterwards calls "ar" to build a static lib.
Both "g++" and "ar" are executed using posix_spawnp()+waitpid() (fork() has
same behaviour)

The Problem is that "ar" somtimes fails because the object-file I compiled
just before doesn't exist!

It seems like if waitpid() returnns before g++ is actually finished. A
simple sleep of 0.5sec avoids the problem.
The waitpid() seems to behave as expected:
1. wait longer for bigger cpp-files
2. wait-time matches output of -time
3. I get correct exit-code
But the output-file appears later, and output of -time and -v also continue
after waitpid() and even after my application has terminated...

Am I missing something obvoius???
Maybe your g++ is spawning another process and returning without waiting it? Seems an odd behavior (many makefiles would break, just as your program) but that's what the
behavior suggests.
I would strace your g++ looking for file and process creation.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]