VDR corrupts terminal, if started in background

Message ID 20090723135550.315390@gmx.net
State New
Headers

Commit Message

Manuel Reimer July 23, 2009, 1:55 p.m. UTC
  Hello,

while installing my VDR, I noticed, that I always get a "staircase effect" on the terminal, supplied via "-t" switch, as soon as VDR is killed for the first time.

I'm using "runvdr-extreme":
http://www.udo-richter.de/vdr/scripts.html

In runvdr-extreme, the VDR itself is started in background. This, in detail, causes the following (All line numbers for VDR 1.7.8):

- As a background process doesn't have a STDIN, the line, which should store the terminal settings to "savedTm" (Line 171 in vdr.c), just does nothing, but sets "HasStdin" to "false".
- If a terminal device is supplied using "-t" switch, then STDIN, STDOUT and STDERR are connected to it (Line 506 in vdr.c) and "HasStdin" is set to "true".
- Before exit, VDR checks the state of the variable "HasStdin" and resets the terminal status to "savedTm" (Line 1314 in vdr.c), saved on start (which is undefined, now!)

Suggested fix could be something like this (untested!):


CU

Manuel Reimer
  

Patch

--- vdr.c.org   2009-07-23 15:50:42.217445637 +0200
+++ vdr.c       2009-07-23 15:50:44.545594171 +0200
@@ -503,12 +503,13 @@  int main(int argc, char *argv[])
      }
   else if (Terminal) {
      // Claim new controlling terminal
      stdin  = freopen(Terminal, "r", stdin);
      stdout = freopen(Terminal, "w", stdout);
      stderr = freopen(Terminal, "w", stderr);
+     tcgetattr(STDIN_FILENO, &savedTm);
      HasStdin = true;
      }

A working workaround seems to be to execute VDR in the following way:

vdr -t "$TERMINAL" < "$TERMINAL" &