Fork and exec

Hi,

system “mkfifo ttt”
pid = fork
exec (“cat < ttt”) if pid.nil?

exec (“exec cat < ttt”) if pid.nil?

I would expect only one process the real “cat process”, but apparently, ruby
spawned
a process and then a child process, which is the real one.

When you use redirection, ruby invokes /bin/sh and /bin/sh
forks to execute the command.

···

At Thu, 17 Oct 2002 08:26:09 +0900, Meng, Ted mengx@tvratings.com wrote:


Nobu Nakada

When you use redirection, ruby invokes /bin/sh and /bin/sh
forks to execute the command.

Is there any chance Ruby will eventually have its `own’ OS hooks so
that it won’t have to do the above?

/ed

Hi,

When you use redirection, ruby invokes /bin/sh and /bin/sh
forks to execute the command.

Is there any chance Ruby will eventually have its `own’ OS hooks so
that it won’t have to do the above?

Though I’m not sure what you mean by “OS hooks”, do you want to
avoid running /bin/sh?

If so, you need to redirect by yourself in the child process
now.

unless pid = fork
STDIN.reopen(open(“ttt”))
exec(“cat”)
end

new method to start child process with such options may be

desirable.

···

At Sat, 19 Oct 2002 15:10:07 +0900, Edward Wilson wrote:


Nobu Nakada