Added closing of file descriptors to piped process starter (gets rid of ffmpeg junk output), added some extra debugging output to DDV Controller.
This commit is contained in:
		
							parent
							
								
									a3e1bc73ae
								
							
						
					
					
						commit
						cd9ed87802
					
				
					 2 changed files with 10 additions and 3 deletions
				
			
		| 
						 | 
					@ -522,6 +522,7 @@ int main(int argc, char ** argv){
 | 
				
			||||||
                    Response["log"] = Storage["log"];
 | 
					                    Response["log"] = Storage["log"];
 | 
				
			||||||
                    Response["statistics"] = Storage["statistics"];
 | 
					                    Response["statistics"] = Storage["statistics"];
 | 
				
			||||||
                    Response["authorize"]["username"] = TOSTRING(COMPILED_USERNAME);
 | 
					                    Response["authorize"]["username"] = TOSTRING(COMPILED_USERNAME);
 | 
				
			||||||
 | 
					                    Log("UPLK", "Responding to login challenge: " + Request["authorize"]["challenge"].asString());
 | 
				
			||||||
                    Response["authorize"]["password"] = md5(TOSTRING(COMPILED_PASSWORD) + Request["authorize"]["challenge"].asString());
 | 
					                    Response["authorize"]["password"] = md5(TOSTRING(COMPILED_PASSWORD) + Request["authorize"]["challenge"].asString());
 | 
				
			||||||
                    it->H.Clean();
 | 
					                    it->H.Clean();
 | 
				
			||||||
                    it->H.SetBody("command="+HTTP::Parser::urlencode(Response.toStyledString()));
 | 
					                    it->H.SetBody("command="+HTTP::Parser::urlencode(Response.toStyledString()));
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -14,6 +14,7 @@
 | 
				
			||||||
#include <errno.h>
 | 
					#include <errno.h>
 | 
				
			||||||
#include <iostream>
 | 
					#include <iostream>
 | 
				
			||||||
#include <sys/types.h>
 | 
					#include <sys/types.h>
 | 
				
			||||||
 | 
					#include <fcntl.h>
 | 
				
			||||||
#include <pwd.h>
 | 
					#include <pwd.h>
 | 
				
			||||||
#include <getopt.h>
 | 
					#include <getopt.h>
 | 
				
			||||||
#include <stdlib.h>
 | 
					#include <stdlib.h>
 | 
				
			||||||
| 
						 | 
					@ -147,11 +148,14 @@ pid_t Util::Procs::Start(std::string name, std::string cmd, std::string cmd2){
 | 
				
			||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  int devnull = open("/dev/null", O_RDWR);
 | 
				
			||||||
  pid_t ret = fork();
 | 
					  pid_t ret = fork();
 | 
				
			||||||
  if (ret == 0){
 | 
					  if (ret == 0){
 | 
				
			||||||
    close(pfildes[0]);
 | 
					    close(pfildes[0]);
 | 
				
			||||||
    dup2(pfildes[1],1);
 | 
					    dup2(pfildes[1],STDOUT_FILENO);
 | 
				
			||||||
    close(pfildes[1]);
 | 
					    close(pfildes[1]);
 | 
				
			||||||
 | 
					    dup2(devnull, STDIN_FILENO);
 | 
				
			||||||
 | 
					    dup2(devnull, STDERR_FILENO);
 | 
				
			||||||
    runCmd(cmd);
 | 
					    runCmd(cmd);
 | 
				
			||||||
  }else{
 | 
					  }else{
 | 
				
			||||||
    if (ret > 0){
 | 
					    if (ret > 0){
 | 
				
			||||||
| 
						 | 
					@ -169,8 +173,10 @@ pid_t Util::Procs::Start(std::string name, std::string cmd, std::string cmd2){
 | 
				
			||||||
  pid_t ret2 = fork();
 | 
					  pid_t ret2 = fork();
 | 
				
			||||||
  if (ret2 == 0){
 | 
					  if (ret2 == 0){
 | 
				
			||||||
    close(pfildes[1]);
 | 
					    close(pfildes[1]);
 | 
				
			||||||
    dup2(pfildes[0],0);
 | 
					    dup2(pfildes[0],STDIN_FILENO);
 | 
				
			||||||
    close(pfildes[0]);
 | 
					    close(pfildes[0]);
 | 
				
			||||||
 | 
					    dup2(devnull, STDOUT_FILENO);
 | 
				
			||||||
 | 
					    dup2(devnull, STDERR_FILENO);
 | 
				
			||||||
    runCmd(cmd2);
 | 
					    runCmd(cmd2);
 | 
				
			||||||
  }else{
 | 
					  }else{
 | 
				
			||||||
    if (ret2 > 0){
 | 
					    if (ret2 > 0){
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue