From patchwork Mon Jan 22 21:09:48 2007 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?TWFya28gTcOka2Vsw6Q=?= X-Patchwork-Id: 12429 Received: from emh07.mail.saunalahti.fi ([62.142.5.117]) by www.linuxtv.org with esmtp (Exim 4.50) id 1H96RA-0002PI-6W for vdr@linuxtv.org; Mon, 22 Jan 2007 22:10:44 +0100 Received: from localhost (a88-115-96-174.elisa-laajakaista.fi [88.115.96.174]) by emh07.mail.saunalahti.fi (Postfix) with ESMTP id C87AE1C6470 for ; Mon, 22 Jan 2007 23:09:48 +0200 (EET) Date: Mon, 22 Jan 2007 23:09:48 +0200 From: Marko =?iso-8859-1?B?TeRrZWzk?= To: VDR Mailing List Subject: Re: [vdr] [RFC] Shutdown rewrite for 1.5.x Message-ID: <20070122210948.GA3084@localhost.localdomain> References: <45947EFD.6000206@gmx.de> <45A4E9F8.5070704@gmx.de> <20070113202823.GB3730@localhost.localdomain> <45A945AF.60004@gmx.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <45A945AF.60004@gmx.de> User-Agent: Mutt/1.5.13 (2006-08-11) X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: VDR Mailing List List-Id: VDR Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Jan 2007 21:10:44 -0000 Status: O X-Status: X-Keywords: X-UID: 11732 On Sat, Jan 13, 2007 at 09:48:47PM +0100, Udo Richter wrote: > >A more important suggestion: Could you please add a notification method > >to status.h for notifying plugins whether VDR is currently in > >interactive mode? > > You can poll this state on your own by calling > Shutdown.IsUserInactive(). Thanks, this seems to work: the display is powered off after the "press any button to cancel shutdown" timeout. However, after a failed shutdown attempt (renaming the shutdown script so that it won't be found), vdr does something to the file descriptor that my plugin opens, and the relay control will fail. This might have something to do with the fact that it is file descriptor 0. There is no stdin, because my runvdr script closes it: exec <&- >> /tmp/vdr.log 2>&1 The problem seems to lie in shutdown.c, in SystemExecSession(). It won't close file descriptor 0, but it will close anything above STDERR_FILENO (which is normally 2). This function appears to show up in strace output as "clone()". Adding close(0) to the function fixes the problem. Do you see any reason why the shutdown script would need to access stdin? (I can see reasons why it would want to access stdout or stderr.) I made a simple patch to softdevice (attached) that seems to work. A similar patch would be needed for the subtitles plugin, to prevent subtitles from appearing on the suspended video screen. Marko Index: softdevice.c =================================================================== RCS file: /cvsroot/softdevice/softdevice/softdevice.c,v retrieving revision 1.76 diff -p -u -r1.76 softdevice.c --- softdevice.c 3 Dec 2006 20:38:18 -0000 1.76 +++ softdevice.c 22 Jan 2007 21:06:00 -0000 @@ -15,6 +15,7 @@ #include #include +#include #include #include @@ -1084,6 +1085,11 @@ bool cPluginSoftDevice::SetupParse(const { // Parse your own setup parameters and store their values. return setupStore.SetupParse(Name, Value); +} + +void cPluginSoftDevice::MainThreadHook(void) +{ + setupStore.shouldSuspend = Shutdown.IsUserInactive(); } VDRPLUGINCREATOR(cPluginSoftDevice); // Don't touch this! Index: softdevice.h =================================================================== RCS file: /cvsroot/softdevice/softdevice/softdevice.h,v retrieving revision 1.13 diff -p -u -r1.13 softdevice.h --- softdevice.h 11 Nov 2006 08:45:17 -0000 1.13 +++ softdevice.h 22 Jan 2007 21:06:00 -0000 @@ -58,6 +58,7 @@ public: virtual cOsdObject *MainMenuAction(void); virtual cMenuSetupPage *SetupMenu(void); virtual bool SetupParse(const char *Name, const char *Value); + virtual void MainThreadHook(void); #if VDRVERSNUM >= 10330 virtual bool Service(const char *Id, void *Data = NULL); #endif