File tree Expand file tree Collapse file tree 2 files changed +17
-9
lines changed Expand file tree Collapse file tree 2 files changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ program example_process_kill
17
17
print * , " Process running:" , running
18
18
19
19
! Wait a bit before killing the process
20
- call sleep(millisec= 1250 ) ! Portable subroutine for sleeping
20
+ call sleep(millisec= 250 )
21
21
22
22
print * , " Killing the process..."
23
23
call kill(process, success)
@@ -31,4 +31,7 @@ program example_process_kill
31
31
! Verify the process is no longer running
32
32
running = is_running(process)
33
33
print * , " Process running after kill:" , running
34
+
35
+ stop 0
36
+
34
37
end program example_process_kill
Original file line number Diff line number Diff line change 8
8
#ifdef _WIN32
9
9
#include <windows.h>
10
10
#else
11
+ #define _POSIX_C_SOURCE 199309L
11
12
#include <sys/wait.h>
12
13
#include <unistd.h>
13
14
#include <time.h>
@@ -317,15 +318,19 @@ void process_wait(float seconds)
317
318
DWORD dwMilliseconds = 1000 * seconds ;
318
319
Sleep (dwMilliseconds );
319
320
#else
320
- int uSeconds = ( int ) 1.0e6 * seconds ;
321
+ int ierr ;
321
322
322
- struct timespec t ;
323
-
324
- t .tv_sec = seconds ;
325
- t .tv_nsec = seconds * 1000000 ;
326
-
327
- int ierr = nanosleep (& t , NULL );
328
-
323
+ struct timespec ts_remaining ;
324
+ ts_remaining .tv_sec = seconds ;
325
+ ts_remaining .tv_nsec = seconds * 1000000000L ;
326
+
327
+ do
328
+ {
329
+ struct timespec ts_sleep = ts_remaining ;
330
+ ierr = nanosleep (& ts_sleep , & ts_remaining );
331
+ }
332
+ while ((EINTR == errno ) && (-1 == ierr ));
333
+
329
334
if (ierr != 0 ){
330
335
switch (errno ){
331
336
case EINTR :
You can’t perform that action at this time.
0 commit comments