From 792b39f941abcad4c39269abcb03c8ba364cab50 Mon Sep 17 00:00:00 2001
From: Gavin Hurlbut <ghurlbut@mythtv.org>
Date: Sun, 9 Jan 2011 14:49:47 -0800
Subject: [PATCH 2/2] Move timeout setting to before fork
---
mythtv/libs/libmythdb/system-unix.cpp | 12 ++++++------
mythtv/libs/libmythdb/system-windows.cpp | 11 +++++------
2 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/mythtv/libs/libmythdb/system-unix.cpp b/mythtv/libs/libmythdb/system-unix.cpp
index 0f29c6e..f96339d 100644
|
a
|
b
|
void MythSystemUnix::Fork(time_t timeout)
|
| 626 | 626 | if (GetSetting("SetDirectory") && !dir.isEmpty()) |
| 627 | 627 | directory = strdup(dir.toUtf8().constData()); |
| 628 | 628 | |
| | 629 | /* Do this before forking in case the child miserably fails */ |
| | 630 | m_timeout = timeout; |
| | 631 | if( timeout ) |
| | 632 | m_timeout += time(NULL); |
| | 633 | |
| 629 | 634 | pid_t child = fork(); |
| 630 | 635 | |
| 631 | 636 | if (child < 0) |
| … |
… |
void MythSystemUnix::Fork(time_t timeout)
|
| 642 | 647 | m_pid = child; |
| 643 | 648 | SetStatus( GENERIC_EXIT_RUNNING ); |
| 644 | 649 | |
| 645 | | m_timeout = timeout; |
| 646 | | |
| 647 | 650 | VERBOSE(VB_SYSTEM|VB_EXTRA, |
| 648 | 651 | QString("Managed child (PID: %1) has started! " |
| 649 | 652 | "%2%3 command=%4, timeout=%5") |
| 650 | 653 | .arg(m_pid) .arg(GetSetting("UseShell") ? "*" : "") |
| 651 | 654 | .arg(GetSetting("RunInBackground") ? "&" : "") |
| 652 | | .arg(GetLogCmd()) .arg(m_timeout)); |
| 653 | | |
| 654 | | if( timeout ) |
| 655 | | m_timeout += time(NULL); |
| | 655 | .arg(GetLogCmd()) .arg(timeout)); |
| 656 | 656 | |
| 657 | 657 | /* close unused pipe ends */ |
| 658 | 658 | CLOSE(p_stdin[0]); |
diff --git a/mythtv/libs/libmythdb/system-windows.cpp b/mythtv/libs/libmythdb/system-windows.cpp
index 2e390c5..df92dfd 100644
|
a
|
b
|
void MythSystemWindows::Fork(time_t timeout)
|
| 633 | 633 | PROCESS_INFORMATION pi; |
| 634 | 634 | ZeroMemory(&pi, sizeof(PROCESS_INFORMATION)); |
| 635 | 635 | |
| | 636 | m_timeout = timeout; |
| | 637 | if( timeout ) |
| | 638 | m_timeout += time(NULL); |
| | 639 | |
| 636 | 640 | bool success = CreateProcess(NULL, |
| 637 | 641 | command, // command line |
| 638 | 642 | NULL, // process security attributes |
| … |
… |
void MythSystemWindows::Fork(time_t timeout)
|
| 655 | 659 | m_child = pi.hProcess; |
| 656 | 660 | SetStatus( GENERIC_EXIT_RUNNING ); |
| 657 | 661 | |
| 658 | | m_timeout = timeout; |
| 659 | | |
| 660 | 662 | VERBOSE(VB_SYSTEM|VB_EXTRA, |
| 661 | 663 | QString("Managed child (Handle: %1) has started! " |
| 662 | 664 | "%2%3 command=%4, timeout=%5") |
| 663 | 665 | .arg((long long)m_child) |
| 664 | 666 | .arg(GetSetting("UseShell") ? "*" : "") |
| 665 | 667 | .arg(GetSetting("RunInBackground") ? "&" : "") |
| 666 | | .arg(GetLogCmd()) .arg(m_timeout)); |
| 667 | | |
| 668 | | if( timeout ) |
| 669 | | m_timeout += time(NULL); |
| | 668 | .arg(GetLogCmd()) .arg(timeout)); |
| 670 | 669 | |
| 671 | 670 | /* close unused pipe ends */ |
| 672 | 671 | CLOSE(p_stdin[0]); |