summaryrefslogtreecommitdiff
path: root/vdr.c
diff options
context:
space:
mode:
Diffstat (limited to 'vdr.c')
-rw-r--r--vdr.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/vdr.c b/vdr.c
index 8f22f11..bec5133 100644
--- a/vdr.c
+++ b/vdr.c
@@ -22,7 +22,7 @@
*
* The project's page is at http://www.cadsoft.de/people/kls/vdr
*
- * $Id: vdr.c 1.137 2002/12/08 13:34:39 kls Exp $
+ * $Id: vdr.c 1.139 2002/12/13 16:01:09 kls Exp $
*/
#include <getopt.h>
@@ -81,7 +81,7 @@ int main(int argc, char *argv[])
// Save terminal settings:
struct termios savedTm;
- tcgetattr(STDIN_FILENO, &savedTm);
+ bool HasStdin = tcgetpgrp(STDIN_FILENO) == getpid() && tcgetattr(STDIN_FILENO, &savedTm) == 0;
// Initiate locale:
@@ -386,7 +386,7 @@ int main(int argc, char *argv[])
new cLircRemote("/dev/lircd");
#endif
#if defined(REMOTE_KBD)
- if (!DaemonMode)
+ if (!DaemonMode && HasStdin)
new cKbdRemote;
#endif
Interface->LearnKeys();
@@ -424,6 +424,7 @@ int main(int argc, char *argv[])
time_t LastActivity = 0;
int MaxLatencyTime = 0;
bool ForceShutdown = false;
+ bool UserShutdown = false;
if (WatchdogTimeout > 0) {
dsyslog("setting watchdog timer to %d seconds", WatchdogTimeout);
@@ -539,6 +540,7 @@ int main(int argc, char *argv[])
ForceShutdown = true;
}
LastActivity = 1; // not 0, see below!
+ UserShutdown = true;
break;
default: break;
}
@@ -647,7 +649,7 @@ int main(int argc, char *argv[])
Interface->Info(tr("Editing process finished"));
}
}
- if (!Interact && ((!cRecordControls::Active() && !cCutter::Active() && !Interface->HasSVDRPConnection()) || ForceShutdown)) {
+ if (!Interact && ((!cRecordControls::Active() && !cCutter::Active() && (!Interface->HasSVDRPConnection() || UserShutdown)) || ForceShutdown)) {
time_t Now = time(NULL);
if (Now - LastActivity > ACTIVITYTIMEOUT) {
// Shutdown:
@@ -665,12 +667,13 @@ int main(int argc, char *argv[])
else
LastActivity = 1;
}
- bool UserShutdown = key == kPower;
if (UserShutdown && Next && Delta <= Setup.MinEventTimeout * 60 && !ForceShutdown) {
char *buf;
asprintf(&buf, tr("Recording in %d minutes, shut down anyway?"), Delta / 60);
if (Interface->Confirm(buf))
ForceShutdown = true;
+ else
+ UserShutdown = false;
free(buf);
}
if (!Next || Delta > Setup.MinEventTimeout * 60 || ForceShutdown) {
@@ -694,6 +697,7 @@ int main(int argc, char *argv[])
signal(SIGALRM, SIG_IGN);
}
LastActivity = time(NULL); // don't try again too soon
+ UserShutdown = false;
continue; // skip the rest of the housekeeping for now
}
}
@@ -724,7 +728,8 @@ int main(int argc, char *argv[])
isyslog("exiting");
if (SysLogLevel > 0)
closelog();
- tcsetattr(STDIN_FILENO, TCSANOW, &savedTm);
+ if (HasStdin)
+ tcsetattr(STDIN_FILENO, TCSANOW, &savedTm);
if (cThread::EmergencyExit()) {
esyslog("emergency exit!");
return 1;