"Alexander Yaworsky" yaworsky@migusoft.ru writes:
- if( WAIT_FAILED == r )
- {
last_error = GetLastError();
CloseHandle( procinfo.hProcess );
goto done;
- }
- ReleaseSemaphore(data, 1, NULL);
- if( r == WAIT_FAILED)
return FALSE;
- /* allright */
- CloseHandle( procinfo.hProcess );
- last_error = 0;
- ret = TRUE;
- return TRUE;
+done:
- CloseHandle( wait );
- ReleaseSemaphore(data, 1, NULL);
- CloseHandle( data );
- SetLastError( last_error );
- return ret;
You should never need to do that sort of thing. CloseHandle and ReleaseSemaphore won't change last error if they are called for valid handles, and if they are not you are just hiding a bug. Also, you very probably don't want to set last error to 0 on success, unless you have clear evidence that Windows does it in this case too.