2
Answers

problem in checking status process PID in c.

rohit kumar

rohit kumar

7y
1.3k
1
I wrote a small program in C.
 
But when i compile it on my pc it goes to " loop" and my pc crashed.
 
program :
 
#include <stdlib.h>
int main()
{
label:;
system("start sleep.exe ");
goto label;
return 0;
}
Solution required:
1) Check sleep.exe is runing or not in process task list of win7.
2)if not running then run sleep.exe.
3)else goto label: for further checking.
program may be something like this:
#include <stdlib.h>
int main()
{
label:;
IF process sleep.exe is runing then{goto label:}
system("start sleep.exe ");
goto label;
return 0;
}
Answers (2)
0
rohit kumar

rohit kumar

NA 6 1.4k 7y
@Laxmidhar Sahoo
 
Sir, Here i need some perameter in C which can check whether my exe file(http server) running or not and with its feedback,if not ruuning then it will agian start my exe file(http server). Do you know any command in C like DOS which can check and restart exe when it is stop.??
 
see this one here in DOS we can check process is runing or not if ruuing then error=0 so it will jump to line loop(last line) and if not ruuing then it will jump to next line run that exe then agin go to loop(1st line) for further checking.
 
:loop
tasklist /FI "IMAGENAME eq httpserver.exe" 2>NUL | find /I /V "httpserver.exe">NUL
if "%ERRORLEVEL%"=="0" goto loop
httpserver.exe hostipaddress command
goto loop
 
Thank you
(I WANT TO DO THIS IN C Sir CAN YOU??)
0
Laxmidhar Sahoo

Laxmidhar Sahoo

NA 2.3k 1.4k 7y
instead of label:;
simple label: