From: Yohanes Santoso Date: 2006-07-12T05:28:32+09:00 Subject: Re: Processes and Portability Name Name writes: > I want this to be portable, ie not just *nix, so I can't fork. It is because of portability issue that I wrote my reply. Being portable does not mean staying of OS-specific features. You can do that, if there is another option for you to take. In this case, however, there is no other. So, being portable for your needs means providing different workaround for different environment. I don't know much about win32, but I know for *nix, you need to do the forking and setup IO redirection yourself (not using IO.popen at all). The other people here have replied about doing this in win32. YS. > However, I am doing something similar to forking in terms of getting the pid > which popen will do. I'm sure if I used fork (which I can't) on program >> logfile, it won't be the pid of program (or it might be, i'm not sure, > but the point is, the logic is messed up since I am doign the extra > redirecting) > > Yohanes Santoso wrote: >> Name Name writes: >> >>> a=IO.popen("program > logfile"), but on Windows this creates two >>> processes, cmd.exe and program. a.pid only gives the pid of cmd.exe. >>> And the behavior on *nix seems to be just the program (although I can be >>> wrong). >> >> The behaviour in *nix depends on your /bin/sh. Some shells gives the >> child's pid, other gives the pid of itself. >> >> pdksh gives the pid of itself. >> bash gives the pid of the child (the behaviour you wanted). >> Don't know about other shells. >> >> The lesson here, you can't get the pid of the child consistently >> unless you do the forking yourself. >> >> YS > > > I know that Harmen. I want the pid of not the intermediate shell, which > is the one I am getting back with popen. I want the pid of the program > itself that I opened. Also, program does produce output and logfile is > writeable, and I need this to run on any system. > >>On Linux that should work if program 'progam_name' produces output and >>file 'logfile' is writable. One of the two processes you mentioned is an >>intermediate shell by the way. > >>Harmen > > -- > Posted via http://www.ruby-forum.com/.