use POSIX qw (setsid);
use File::Spec;
use Carp;
+use Term::ReadKey;
use OSDep;
use Display;
EnterDaemonMode
Execute
GetChildren
+ GetPassword
InArray
PageOutput
PipeOutput
Usage
);
+sub _restoreTerm () {
+ # In case the user hits Ctrl-C
+ print "\nControl-C\n";
+
+ ReadMode 'normal';
+
+ exit;
+} # _restoreTerm
+
sub EnterDaemonMode (;$$$) {
my ($logfile, $errorlog, $pidfile) = @_;
my $file;
- if ($pidfile) {
- $pidfile = File::Spec->rel2abs ($pidfile);
-
- open $file, '>', $pidfile
- or warning "Unable to open pidfile $pidfile for writing - $!";
- } # if
-
# Redirect STDIN to $NULL
open STDIN, '<', $NULL
or error "Can't read $NULL ($!)", 1;
# Write pidfile if specified
if ($pidfile) {
+ $pidfile = File::Spec->rel2abs ($pidfile);
+
+ open $file, '>', $pidfile
+ or warning "Unable to open pidfile $pidfile for writing - $!";
+
print $file "$$\n";
close $file;
return @children;
} # GetChildren
+sub GetPassword (;$) {
+ my ($prompt) = @_;
+
+ $prompt ||= 'Password';
+
+ my $password;
+
+ local $| = 1;
+
+ print "$prompt:";
+
+ $SIG{INT} = \&_restoreTerm;
+
+ ReadMode 'cbreak';
+
+ while () {
+ my $key;
+
+ while (not defined ($key = ReadKey -1)) { }
+
+ if ($key =~ /(\r|\n)/) {
+ print "\n";
+
+ last;
+ } # if
+
+ print '*';
+
+ $password .= $key;
+ } # while
+
+ ReadMode 'restore'; # Reset tty mode before exiting.
+
+ $SIG{INT} = 'DEFAULT';
+
+ return $password;
+} # GetPassword
+
sub InArray ($@) {
my ($item, @array) = @_;
=cut
- open my $pipe, "|$to"
+ open my $pipe, '|', $to
or error "Unable to open pipe - $!", 1;
foreach (@output) {
$pipeToStop ||= $pipe;
close $pipeToStop if $pipeToStop;
+
+ return;
} # StopPipe
sub PageOutput (@) {
return @cleansed_lines;
} else {
- local $/;
+ local $/ = undef;
return <$file>;
} # if
=head2 ClearSCM Perl Modules
-=for html <p><a href="/php/cvs_man.php?file=lib/Display.pm">Display</a></p>
+=for html <p><a href="/php/scm_man.php?file=lib/Display.pm">Display</a></p>
-=for html <p><a href="/php/cvs_man.php?file=lib/Logger.pm">Logger</a></p>
+=for html <p><a href="/php/scm_man.php?file=lib/Logger.pm">Logger</a></p>
-=for html <p><a href="/php/cvs_man.php?file=lib/OSDep.pm">OSDep</a></p>
+=for html <p><a href="/php/scm_man.php?file=lib/OSDep.pm">OSDep</a></p>
=head1 INCOMPATABILITIES