~percona-toolkit-dev/percona-toolkit/update-relay-log-space-limit-docs-fix-bug-949154

« back to all changes in this revision

Viewing changes to bin/pt-show-grants

  • Committer: Daniel Nichter
  • Date: 2012-03-07 21:44:43 UTC
  • Revision ID: daniel@percona.com-20120307214443-onw628wn1l2twaj9
Update Daemon in all tools (bug 944420).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1431
1431
   PTDEBUG && _d('About to fork and daemonize');
1432
1432
   defined (my $pid = fork()) or die "Cannot fork: $OS_ERROR";
1433
1433
   if ( $pid ) {
1434
 
      PTDEBUG && _d('I am the parent and now I die');
 
1434
      PTDEBUG && _d('Parent PID', $PID, 'exiting after forking child PID',$pid);
1435
1435
      exit;
1436
1436
   }
1437
1437
 
 
1438
   PTDEBUG && _d('Daemonizing child PID', $PID);
1438
1439
   $self->{PID_owner} = $PID;
1439
1440
   $self->{child}     = 1;
1440
1441
 
1445
1446
 
1446
1447
   $OUTPUT_AUTOFLUSH = 1;
1447
1448
 
1448
 
   if ( -t STDIN ) {
1449
 
      close STDIN;
1450
 
      open  STDIN, '/dev/null'
1451
 
         or die "Cannot reopen STDIN to /dev/null: $OS_ERROR";
1452
 
   }
 
1449
   PTDEBUG && _d('Redirecting STDIN to /dev/null');
 
1450
   close STDIN;
 
1451
   open  STDIN, '/dev/null'
 
1452
      or die "Cannot reopen STDIN to /dev/null: $OS_ERROR";
1453
1453
 
1454
1454
   if ( $self->{log_file} ) {
 
1455
      PTDEBUG && _d('Redirecting STDOUT and STDERR to', $self->{log_file});
1455
1456
      close STDOUT;
1456
1457
      open  STDOUT, '>>', $self->{log_file}
1457
1458
         or die "Cannot open log file $self->{log_file}: $OS_ERROR";
1462
1463
   }
1463
1464
   else {
1464
1465
      if ( -t STDOUT ) {
 
1466
         PTDEBUG && _d('No log file and STDOUT is a terminal;',
 
1467
            'redirecting to /dev/null');
1465
1468
         close STDOUT;
1466
1469
         open  STDOUT, '>', '/dev/null'
1467
1470
            or die "Cannot reopen STDOUT to /dev/null: $OS_ERROR";
1468
1471
      }
1469
1472
      if ( -t STDERR ) {
 
1473
         PTDEBUG && _d('No log file and STDERR is a terminal;',
 
1474
            'redirecting to /dev/null');
1470
1475
         close STDERR;
1471
1476
         open  STDERR, '>', '/dev/null'
1472
1477
            or die "Cannot reopen STDERR to /dev/null: $OS_ERROR";
1473
1478
      }
1474
1479
   }
1475
1480
 
1476
 
   PTDEBUG && _d('I am the child and now I live daemonized');
1477
1481
   return;
1478
1482
}
1479
1483