linux - c program hangs/loops when "sudo -s" command is executed -
I am currently writing a program that will run multiple command (in one line) in CLI with C.
The first order I need to run is BTW, I am doing a web app, the user will write down the command that he wants to execute. Through input requires password , So that the command running the command can wait for the password to enter the program sudo -s . So I go out to test this command alone if the program is running, but the program is hanging while running this command. I wanted to know whether the problem is program or order, so I
ls Run This program works perfectly when I run the
ls command, I think that there is something wrong with the
sudo -s command, There is a need to do something with which This is the job that runs in CLI
int executeCommand (char * command, char * result) {/ * This function runs the command . / / / / * Return value is the command * / int nSuccess = -1; FILE * fp = NULL; Four buffer [1035]; If (command == NULL) render ("command is empty"); If present (result == faucet) ("the result is zero"); If (command! = Null & amp; result! = Null) {fp = popen (command, "r"); If (fp! = NULL) {strcpy (result, "\ 0"); While (FATS (buffer, size (buffer-1, FP)! = Null) {Rebel (result, buffer); } pclose (fp); } nSuccess = 0; } Return nSuccess; }
AJAX will be sent to the server using a
POST request. And the server runs on Linux.
sudo -s
Comments
Post a Comment