diff --git a/HISTORY.rdoc b/HISTORY.rdoc index b67712a..857d284 100644 --- a/HISTORY.rdoc +++ b/HISTORY.rdoc @@ -2,7 +2,7 @@ == Version 2.2.0 - 2013-XX-XX * Chagne XFCE detection to not depend on grep (copiousfreetime/launchy#52 - thanks bogdan) - +* Suppress forked process output (copiousfreetime/launchy#51) == Version 2.1.2 - 2012-08-06 diff --git a/lib/launchy/detect/runner.rb b/lib/launchy/detect/runner.rb index 880674c..0f8a868 100644 --- a/lib/launchy/detect/runner.rb +++ b/lib/launchy/detect/runner.rb @@ -102,11 +102,21 @@ def wet_run( cmd, *args ) class Forkable < Runner def wet_run( cmd, *args ) child_pid = fork do + close_file_descriptors unless Launchy.debug? + Launchy.log("wet_run: before exec in child process") exec( *shell_commands( cmd, *args )) exit! end Process.detach( child_pid ) end + + def close_file_descriptors + [$stdin, $stdout, $stderr].each do |io| + io.reopen( "/dev/null", "r+" ) + end + end + + private :close_file_descriptors end end end