From: Ian Beckwith Date: Tue, 19 Oct 2010 14:30:30 +0000 (+0100) Subject: id3fsd: drop terminal unless verbose X-Git-Tag: debian/1.0-1~30 X-Git-Url: http://erislabs.net/gitweb/?p=id3fs.git;a=commitdiff_plain;h=0bd7f7a4091466e6fefa127463dd23748c1d87d8 id3fsd: drop terminal unless verbose --- diff --git a/sbin/id3fsd b/sbin/id3fsd index 0809985..f55d0c1 100755 --- a/sbin/id3fsd +++ b/sbin/id3fsd @@ -21,6 +21,8 @@ use strict; use Getopt::Long qw(Configure); use ID3FS::DB; use ID3FS::Fuse; +use POSIX; + use vars qw($me); $me=($0=~/(?:.*\/)?(.*)/)[0]; @@ -48,6 +50,22 @@ my $db=ID3FS::DB->new($me, $verbose, 0, $source, $dbpath); exit unless($db); my $fuse=ID3FS::Fuse->new($db, $source, $mountpoint, $verbose, $tagdepth); + +# disassociate from terminal +unless($verbose) +{ + my $pid=fork(); + if(defined($pid)) + { + exit if($pid); # parent + POSIX::setsid(); # child + } + else + { + print "$me: couldn't drop terminal: $!\n"; + } +} + $fuse->run(); sub usage