Sha256: 797ff85c0dedcf76ea6380d7a08cca9e8b06d18a9710d66e4e55c69dba7217db
Contents?: true
Size: 809 Bytes
Versions: 1
Compression:
Stored size: 809 Bytes
Contents
require 'wunderbar' # run command/block as a background daemon module Wunderbar def self.submit(cmd=nil) fork do # detach from tty Process.setsid fork and exit # clear working directory and mask Dir.chdir '/' File.umask 0000 # close open files STDIN.reopen '/dev/null' STDOUT.reopen '/dev/null', 'a' STDERR.reopen STDOUT # clear environment of cgi cruft require 'cgi' ENV.keys.select {|key| key =~ /^HTTP_/}.each do |key| ENV.delete key.dup.untaint end ::CGI::QueryExtension.public_instance_methods.each do |method| ENV.delete method.to_s.upcase end # run cmd and/or block system({'USER' => $USER, 'HOME' => $HOME}, cmd) if cmd yield if block_given? end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wunderbar-1.0.17 | lib/wunderbar/job-control.rb |