C
Chris
(uname -a: Linux srv343.revere.com 2.4.20-30.9 #1 Wed Feb 4 20:44:26
EST 2004 i686 i686 i386 GNU/Linux)
I'm pulling my hair out over here...
I have a program that forks off a child, and uses wait3 to (1) wait
for the child to finish, and to (2) collect and report system usage
info.
Now, in the process of narrowing stuff down, I've come to the
following two lines of code that illustrate the problem:
wait3(&status,0,usage);
printf("...hi...\n\n");
printf(">>> %f \n\n", 67.8);
In theory, the 2nd line should simply print out the number
67.800000... Nothing programmatic or complex going on. However, when
I compile (which gives no errors/warnings) and run, I get this output:
hi....
Segmentation fault
Now, if I comment out the wait3 line (and make no other change
whatsoever), a compile and run gives me:
hi....
....and things seem to be working ok. Also, if I do:
printf(">>> %d",67)
....I get >>> 67 (valid output), with wait3 and without wait3.
So, can anyone think of a reason why printf would smash like this?
Any help is greatly appreciated... Thanks!
EST 2004 i686 i686 i386 GNU/Linux)
I'm pulling my hair out over here...
I have a program that forks off a child, and uses wait3 to (1) wait
for the child to finish, and to (2) collect and report system usage
info.
Now, in the process of narrowing stuff down, I've come to the
following two lines of code that illustrate the problem:
wait3(&status,0,usage);
printf("...hi...\n\n");
printf(">>> %f \n\n", 67.8);
In theory, the 2nd line should simply print out the number
67.800000... Nothing programmatic or complex going on. However, when
I compile (which gives no errors/warnings) and run, I get this output:
hi....
Segmentation fault
Now, if I comment out the wait3 line (and make no other change
whatsoever), a compile and run gives me:
hi....
....and things seem to be working ok. Also, if I do:
printf(">>> %d",67)
....I get >>> 67 (valid output), with wait3 and without wait3.
So, can anyone think of a reason why printf would smash like this?
Any help is greatly appreciated... Thanks!