From 1af9fe2bc8dc8b6e24157da522f72bbd32359ba2 Mon Sep 17 00:00:00 2001
From: Gavin Hurlbut <gjhurlbu@gmail.com>
Date: Thu, 7 Oct 2010 01:17:27 -0700
Subject: [PATCH] Remove VERBOSE from myth_system child
diff --git a/mythtv/libs/libmythdb/mythsystem.cpp b/mythtv/libs/libmythdb/mythsystem.cpp
index 7a4bcdb..28a5da1 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 | |
376 | 377 | pid_t child = fork(); |
377 | 378 | |
378 | 379 | if (child < 0) |
379 | 380 | { |
380 | | /* Fork failed */ |
| 381 | /* Fork failed, still in parent */ |
381 | 382 | VERBOSE(VB_GENERAL, (LOC_ERR + "fork() failed because %1") |
382 | 383 | .arg(strerror(errno))); |
383 | 384 | result = GENERIC_EXIT_NOT_OK; |
… |
… |
pid_t myth_system_fork(const QString &command, uint &result) |
385 | 386 | } |
386 | 387 | else if (child == 0) |
387 | 388 | { |
388 | | /* 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"); |
| 389 | /* Child - NOTE: it is not safe to use VERBOSE between the fork and |
| 390 | * execl calls in the child. It causes occasional locking issues that |
| 391 | * cause deadlocked child processes. */ |
394 | 392 | |
395 | 393 | /* Close all open file descriptors except stdout/stderr */ |
396 | 394 | for (int i = sysconf(_SC_OPEN_MAX) - 1; i > 2; i--) |
… |
… |
pid_t myth_system_fork(const QString &command, uint &result) |
403 | 401 | // Note: dup2() will close old stdin descriptor. |
404 | 402 | if (dup2(fd, 0) < 0) |
405 | 403 | { |
406 | | VERBOSE(VB_GENERAL, LOC_ERR + |
| 404 | // Can't use VERBOSE due to locking fun. |
| 405 | QString message = LOC_ERR + |
407 | 406 | "Cannot redirect /dev/null to standard input," |
408 | | "\n\t\t\tfailed to duplicate file descriptor." + ENO); |
| 407 | "\n\t\t\tfailed to duplicate file descriptor." + ENO; |
| 408 | cerr << message.constData(); |
409 | 409 | } |
410 | 410 | close(fd); |
411 | 411 | } |
412 | 412 | else |
413 | 413 | { |
414 | | VERBOSE(VB_GENERAL, LOC_ERR + "Cannot redirect /dev/null " |
415 | | "to standard input, failed to open." + ENO); |
| 414 | // Can't use VERBOSE due to locking fun. |
| 415 | QString message = LOC_ERR + "Cannot redirect /dev/null " |
| 416 | "to standard input, failed to open." + ENO; |
| 417 | cerr << message.constData(); |
416 | 418 | } |
417 | 419 | |
418 | 420 | /* Run command */ |
419 | 421 | execl("/bin/sh", "sh", "-c", command.toUtf8().constData(), (char *)0); |
420 | 422 | if (errno) |
421 | 423 | { |
422 | | VERBOSE(VB_GENERAL, (LOC_ERR + "execl() failed because %1") |
423 | | .arg(strerror(errno))); |
| 424 | // Can't use VERBOSE due to locking fun. |
| 425 | QString message = LOC_ERR + QString("execl() failed because %1") |
| 426 | .arg(strerror(errno)); |
| 427 | cerr << message.constData(); |
424 | 428 | } |
425 | 429 | |
426 | 430 | /* Failed to exec */ |