#include <windows.h>
#include <process.h>
#include <sys/wait.h>
#include <io.h>

pid_t
waitpid (pid_t pid, int *stat_loc, int options)
{
    DWORD timeout;

    if (options == WNOHANG) {
	timeout = 0;
    } else {
	timeout = INFINITE;
    }
    if (WaitForSingleObject((HANDLE) pid, timeout) == WAIT_OBJECT_0) {
	pid = _cwait(stat_loc, pid, 0);
	return pid;
    }
    return 0;
}

