Sleep() ignored when profiling


#1

I have added the sleep(100); command just before main() exits, and when I run the program it waits as expected. However, when I profile, the app runs and exits as if the sleep(100); command were not there at all. Google searches have not really found any mention of this or similar issues.

Thanks,
Ben


#2

[quote=“bclinkinbeard”]I have added the sleep(100); command just before main() exits, and when I run the program it waits as expected. However, when I profile, the app runs and exits as if the sleep(100); command were not there at all. Google searches have not really found any mention of this or similar issues.

Thanks,
Ben[/quote]

Is it right before the return 0; line?


#3

That seems odd. I might go so far as to say “Unlikely”. Are you sure you are building and running the version that has the call to sleep? (Save the file, build it, and run it again.)


#4

Yep, sleep(100); is on the line preceding return 0; I realize it sounds bizarre, but if I click the Run button it executes the app, keeping the Stop button enabled until sleep() times out or I click it. When I use Product > Profile the Stop button flashes enabled for a split second then goes back to disabled. I can record a quick screencast if you think it might help, but it sounds like maybe reinstalling XCode is my only hope.

Thanks,
Ben


#5

Additionally, the Console stays completely empty when I attempt to profile, like the app never even runs to begin with.


#6

When you are profiling, the app is running inside the Instruments application, right?


#7

Nope, the app was not running. I reinstalled XCode and everything seems to work just fine now. No changes to code at all, but it works as expected. Weird.


#8

I’m having the same issue. I verified that the sleep() statement is right before the return statement. I even reinstalled like bclinkinbeard suggested. I even when so far as to try on a second system with the same results.

Oddly, I get the pause if I move the sleep() call to the top of main() but, obviously, I don’t get the data.


#9

Yeah, you can disregard that. I forgot to initialize my loop properly.