John Freeman
John Freeman

Reputation: 2692

How can I create a subprocess on Windows that sleeps for a second?

I'm trying what I thought would be "hello world" to learn the analog of fork/exec on Windows: create a subprocess that sleeps for one second and then exits. GNU coreutils have a nice sleep tool in /bin. There seems to be no analog on Windows. What is a simple tool I can invoke as a subprocess on Windows?

Upvotes: 0

Views: 67

Answers (1)

Eryk Sun
Eryk Sun

Reputation: 34270

You can wait via timeout.exe /t 1 /nobreak. It displays a countdown in the console. If this is a problem, you can use the creation flag CREATE_NO_WINDOW to force it to allocate a new console that has no window. The /nobreak option can be omitted in this case, since there's no window for a user to press enter to bypass the countdown.

Upvotes: 1

Related Questions