// dllmain.cpp : DLL アプリケーションのエントリ ポイントを定義します。
#include "stdafx.h"

pid_t waitpid(pid_t pid, int *status, int options)
{
	DWORD timeout = INFINITE;
	DWORD waitcode;

	if(options & WNOHANG)
		timeout = 0;

	waitcode = WaitForSingleObject((HANDLE)pid, timeout);
	switch (waitcode) {
	case WAIT_OBJECT_0:
		return pid;
	case WAIT_TIMEOUT:
		return 0;
	}

	return -1;
}

int kill(pid_t pid, int sig)
{
	return TerminateProcess((HANDLE)pid, 0);
}

int pipe(HANDLE pipefd[2])
{
	return CreatePipe(&pipefd[0], &pipefd[1], NULL, 0);
}

BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
					 )
{
	switch (ul_reason_for_call)
	{
	case DLL_PROCESS_ATTACH:
	case DLL_THREAD_ATTACH:
	case DLL_THREAD_DETACH:
	case DLL_PROCESS_DETACH:
		break;
	}
	return TRUE;
}

