summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2013-04-13 13:20:45 +0200
committerYorhel <git@yorhel.nl>2013-04-13 13:22:05 +0200
commit19bd62ebe6fbbe4f21cf6ad943d1d4ca654d0086 (patch)
treec83187b015d1bf5d632173fecd216e8fa56d6646
parentb88b6f719d9f15f3d8bbe5559d040bc8fe6f1dbb (diff)
globster-launch: Pass unrecognized options to globster + unblock I/O
This doesn't require keeping this script in sync when new options are added to globster. Setting O_NONBLOCK flag may fix some buffering issues with the log redirection.
-rw-r--r--doc/globster-launch.pod7
-rwxr-xr-xutil/globster-launch25
2 files changed, 16 insertions, 16 deletions
diff --git a/doc/globster-launch.pod b/doc/globster-launch.pod
index f94019b..95dd678 100644
--- a/doc/globster-launch.pod
+++ b/doc/globster-launch.pod
@@ -26,6 +26,9 @@ use a firewall that disallows connections from unwanted users in your network!
=head1 OPTIONS
+The options recognized by globster-launch are listed below. Any unrecognized
+options are passed through to L<globster(1)> unmodified.
+
=over
=item --path I<path>
@@ -47,10 +50,6 @@ standard error regardless of this option.
Just print the D-Bus address on standard output instead of the instructions. As
with --quiet, this does not suppress log output.
-=item --log-level, -c, --session-dir, -n
-
-These options are passed through to L<globster(1)>.
-
=back
=head1 SEE ALSO
diff --git a/util/globster-launch b/util/globster-launch
index e73f053..c14601b 100755
--- a/util/globster-launch
+++ b/util/globster-launch
@@ -10,24 +10,21 @@ use warnings;
use File::Temp 'tempfile';
use IPC::Open3;
use IO::Select;
-use Getopt::Long;
+use Fcntl;
+
my $conf_path = '';
my $conf_tcp = '';
my($conf_quiet, $conf_print_addr);
my @conf_globster;
-GetOptions(
- 'path=s' => \$conf_path,
- 'tcp=s' => \$conf_tcp,
- 'quiet' => \$conf_quiet, # Doesn't stop output from globster to be redirected
- 'print-address' => \$conf_print_addr,
- # Pass-through Globster options
- 'log-level=s' => sub { push @conf_globster, "--$_[0]", $_[1] },
- 'session-dir=s' => sub { push @conf_globster, "--$_[0]", $_[1] },
- 'c=s' => sub { push @conf_globster, "-$_[0]", $_[1] },
- 'n' => sub { push @conf_globster, "-$_[0]" },
-);
+while(local $_ = shift) {
+ if(/^--path$/) { $conf_path = shift; next; }
+ if(/^--tcp$/) { $conf_tcp = shift; next; }
+ if(/^--quiet$/) { $conf_quiet = 1; next; }
+ if(/^--print-address$/) { $conf_print_addr = 1; next; }
+ push @conf_globster, $_;
+}
die "Can't set --path and --tcp at the same time\n" if $conf_path && $conf_tcp;
@@ -154,6 +151,10 @@ sub startGlobster {
sub runLoop {
# Forward globster stdout/stderr to our own stdout/stderr.
my $s = IO::Select->new();
+ eval {
+ fcntl($glob_r, F_SETFL, fcntl($glob_r, F_GETFL, 0) | O_NONBLOCK);
+ fcntl($glob_e, F_SETFL, fcntl($glob_e, F_GETFL, 0) | O_NONBLOCK);
+ };
$s->add($glob_r);
$s->add($glob_e);
while(my @r = $s->can_read) {