From: Aredridel Date: 2003-07-06T00:45:59+09:00 Subject: Re: Ruby, Threads and Processes On Sat, 2003-07-05 at 03:04, George Moschovitis wrote: > > When you use %x{}, ruby use a pipe you can see it > > ... > > Guy Decoux > > Hi, > > thanks for your time, but i do not understand the answer. Let me > rephrase the question: > > From what i have seen in the docs, Kernel.exec executes an OS command > in the current process, and Kernel.system creates a new subprocess to > execute the command. The question is, %x{} is an alias for exec or > system? ie does it create a new process? Definately a new process. if any program (under *nix -- win32 is totally different this way) calls the exec() function (in C), the process calling it is replaced by the new program. The usual way a C program spawns a sub-process is with a fork() call, to make a copy of the parent process, then one of them will call exec(), getting itself replaced with the subprocess. Not entirely intuitive, but it works. If Ruby were to use exec, the script would stop at the first use of %x{}. %x{} is an alias for system.