From 9a6535fba1ccef84fd8ede246912e0d7a7bf3eef Mon Sep 17 00:00:00 2001
From: Gavin Hurlbut <gjhurlbu@gmail.com>
Date: Thu, 7 Oct 2010 01:17:27 -0700
Subject: [PATCH] Redo the verbose_lock in myth_system
diff --git a/mythtv/libs/libmythdb/mythsystem.cpp b/mythtv/libs/libmythdb/mythsystem.cpp
index 7a4bcdb..b6196dd 100644
a
|
b
|
pid_t myth_system_fork(const QString &command, uint &result) |
373 | 373 | { |
374 | 374 | QString LOC_ERR = QString("myth_system('%1'): Error: ").arg(command); |
375 | 375 | VERBOSE(VB_GENERAL, QString("Launching: %1") .arg(command)); |
| 376 | |
| 377 | // Due to the possibility of forking during a call to currentDateTime from within |
| 378 | // VERBOSE, and thereby breaking VERBOSE in the children, lock the verbose_mutex |
| 379 | // to prevent this from ever happening. |
| 380 | verbose_mutex.lock(); |
| 381 | |
376 | 382 | pid_t child = fork(); |
377 | 383 | |
| 384 | verbose_mutex.unlock(); |
| 385 | |
378 | 386 | if (child < 0) |
379 | 387 | { |
380 | 388 | /* Fork failed */ |
… |
… |
pid_t myth_system_fork(const QString &command, uint &result) |
386 | 394 | else if (child == 0) |
387 | 395 | { |
388 | 396 | /* Child */ |
389 | | /* In case we forked WHILE it was locked */ |
390 | | bool unlocked = verbose_mutex.tryLock(); |
391 | | verbose_mutex.unlock(); |
392 | | if( !unlocked ) |
393 | | VERBOSE(VB_GENERAL, "Cleared parent's verbose lock"); |
394 | | |
395 | 397 | /* Close all open file descriptors except stdout/stderr */ |
396 | 398 | for (int i = sysconf(_SC_OPEN_MAX) - 1; i > 2; i--) |
397 | 399 | close(i); |