@@ -109,9 +109,6 @@ void process_create_windows(const char* cmd, const char* stdin_stream,
109109 snprintf (full_cmd , full_cmd_len , "%s" , cmd );
110110 }
111111
112- // Free the allocated memory
113- free (full_cmd );
114-
115112 // Create the process
116113 BOOL success = CreateProcess (
117114 NULL , // Application name
@@ -126,8 +123,11 @@ void process_create_windows(const char* cmd, const char* stdin_stream,
126123 & pi // PROCESS_INFORMATION
127124 );
128125
126+ // Free the allocated memory
127+ free (full_cmd );
128+
129129 if (!success ) {
130- fprintf (stderr , "CreateProcess failed (%lud ).\n" , GetLastError ());
130+ fprintf (stderr , "CreateProcess failed (%lu ).\n" , GetLastError ());
131131 return ;
132132 }
133133
@@ -333,15 +333,18 @@ bool process_kill(stdlib_pid pid)
333333void process_wait (float seconds )
334334{
335335#ifdef _WIN32
336- DWORD dwMilliseconds = 1000 * seconds ;
336+ DWORD dwMilliseconds = ( DWORD ) ( seconds * 1000 ) ;
337337 Sleep (dwMilliseconds );
338338#else
339339 int ierr ;
340340
341- struct timespec ts_remaining ;
342- ts_remaining .tv_sec = seconds ;
343- ts_remaining .tv_nsec = seconds * 1000000000L ;
344-
341+ unsigned int ms = (unsigned int ) (seconds * 1000 );
342+ struct timespec ts_remaining =
343+ {
344+ ms / 1000 ,
345+ (ms % 1000 ) * 1000000L
346+ };
347+
345348 do
346349 {
347350 struct timespec ts_sleep = ts_remaining ;
@@ -358,7 +361,7 @@ void process_wait(float seconds)
358361 fprintf (stderr , "nanosleep() bad milliseconds value\n" );
359362 exit (EINVAL );
360363 case EFAULT :
361- fprintf (stderr , "nanosleep() bad milliseconds value \n" );
364+ fprintf (stderr , "nanosleep() problem copying information to user space \n" );
362365 exit (EFAULT );
363366 case ENOSYS :
364367 fprintf (stderr , "nanosleep() not supported on this system\n" );
0 commit comments