On 07 Jun 2007 Anssi Hannula <[EMAIL PROTECTED]> wrote:
> Attached is a patch for mplayer plugin which closes file descriptors
> (except 0, 1, 2) when forking mplayer script.
Thanks.
I took over that with slight changes. The final patch is attached.
Could I please have some feedback if it's working as good as
yours?
Regards.
--
Stefan Huelswitt
[EMAIL PROTECTED] | http://www.muempf.de/
--- player-mplayer.c
+++ player-mplayer.c
@@ -383,17 +383,19 @@
dsyslog("mplayer: mplayer child started (pid=%d)", getpid());
if(MPlayerSetup.SlaveMode) {
- close(inpipe[1]);
- close(outpipe[0]);
if(dup2(inpipe[0],STDIN_FILENO)<0 ||
dup2(outpipe[1],STDOUT_FILENO)<0 ||
dup2(outpipe[1],STDERR_FILENO)<0) {
esyslog("ERROR: dup2() failed in MPlayer child: (%d)
%s",errno,strerror(errno));
exit(127);
}
- close(inpipe[0]);
- close(outpipe[1]);
}
+ else {
+ int nfd=open("/dev/null",O_RDONLY);
+ if(nfd<0 || dup2(nfd,STDIN_FILENO)<0)
+ esyslog("ERROR: redirect of STDIN failed in MPlayer child: (%d)
%s",errno,strerror(errno));
+ }
+ for(int i=getdtablesize()-1; i>STDERR_FILENO; i--) close(i);
char cmd[64+PATH_MAX*2], aid[20];
char *fname=Quote(file->FullPath());
_______________________________________________
vdr mailing list
vdr@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr