A ruby expression by jack tang from his posterous page Software Is Art!
ThreadA: exec_point_a -> exec_point_b -> exec_point_c
ThreadB: exec_point_a -> exec_point_b -> ...
In Ruby 1.8
ObjectSpace.each_object(IO) do |io|
unless [STDIN, STDOUT, STDERR].include?(io)
unless(io.closed?)
begin
io.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
rescue ::Exception => err
end
end
end
end
In Ruby 1.9
ObjectSpace.each_object(IO) do |io|
unless [STDIN, STDOUT, STDERR].include?(io)
unless(io.closed?)
begin
io.close_on_exec= true
rescue ::Exception => err
end
end
end
end
[I believe ee cummings would be proud. end end end]
A bit more information if you understand this kind of poetry:
Fork-exec is a commonly used technique in Unix whereby an executing process spawns a new program. fork() is the name of the system call that the parent process uses to "divide" itself ("fork") into two identical processes. After calling fork(), the created child process is actually an exact copy of the parent - which would probably be of limited use - so it replaces itself with another process using the system call exec().
Here is the full post on Software Is Art!
@jmacofearth
permalink: http://bit.ly/fork-exec-poetry
No comments:
Post a Comment