@echo off set count=0 :loop set /a count=%count%+1 echo Count %count% @echo on perl -e "if ($pid=fork){Win32::Sleep(0); kill(9, $pid); Win32::Sleep(0)} else {sleep 1000}" if errorlevel 1 goto exit @echo off goto loop :exit ECHO.%ERRORLEVEL% #### The outcome of kill on a pseudo-process is unpredictable. It depends on the timing in the Windows operating system. Code that has worked, suddenly can fail, resulting in errors which are difficult to find.