Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > open3 "sh -c" problem with pipes or redirect

Reply
Thread Tools

open3 "sh -c" problem with pipes or redirect

 
 
VANOSPAM
Guest
Posts: n/a
 
      09-24-2009
I have a perl programming that has been running for the last 10 or so
years. It manages other processes, capturing all outputs into a
common logfile and killing dormant processes (no output) after a given
amount of time. The user can print processes up or down as needed.
It utilizes the Event.pm module and it works fine. Now I I have the
need to either run a process that utilizes a pipe "x | y" or setup two
separate processes and redirect stdin/stdout to use a named pipe ("x
>name_pipe" and "y <name_pipe"). In either case, the open3 call uses

a "sh -c" to execute the command. The pid that is returned is the pid
of the shell command and when I attempt to terminate the process only
the shell command is killed, not the children.

I suspect the answer is to modify the stdin/stdout file handles as
needed and pass those to open3. Is this the correct solution or is
there another way?

Currently, this is running on Solaris 8 & 10, sparc and Intel. There
is no need for portability to windows.

Thanx.

Brad
 
Reply With Quote
 
 
 
 
C.DeRykus
Guest
Posts: n/a
 
      09-24-2009
On Sep 24, 9:30*am, VANOSPAM <(E-Mail Removed)> wrote:
> I have a perl programming that has been running for the last 10 or so
> years. *It manages other processes, capturing all outputs into a
> common logfile and killing dormant processes (no output) after a given
> amount of time. *The user can print processes up or down as needed.
> It utilizes the Event.pm module and it works fine. *Now I I have the
> need to either run a process that utilizes a pipe "x | y" or setup two
> separate processes and redirect stdin/stdout to use a named pipe ("x>name_pipe" and "y <name_pipe"). *In either case, the open3 call uses
>
> a "sh -c" to execute the command. *The pid that is returned is the pid
> of the shell command and when I attempt to terminate the process only
> the shell command is killed, not the children.
>
> I suspect the answer is to modify the stdin/stdout file handles as
> needed and pass those to open3. *Is this the correct solution or is
> there another way?
>
> Currently, this is running on Solaris 8 & 10, sparc and Intel. *There
> is no need for portability to windows.
>


Since portability wouldn't be an issue, you could try a negative
signal to target an entire process group. See perldoc -f kill or
perldoc perlipc for details.

--
Charles DeRykus

 
Reply With Quote
 
 
 
 
VANOSPAM
Guest
Posts: n/a
 
      09-24-2009
On Sep 24, 2:37*pm, "C.DeRykus" <(E-Mail Removed)> wrote:
> On Sep 24, 9:30*am, VANOSPAM <(E-Mail Removed)> wrote:
>
>
>
> > I have a perl programming that has been running for the last 10 or so
> > years. *It manages other processes, capturing all outputs into a
> > common logfile and killing dormant processes (no output) after a given
> > amount of time. *The user can print processes up or down as needed.
> > It utilizes the Event.pm module and it works fine. *Now I I have the
> > need to either run a process that utilizes a pipe "x | y" or setup two
> > separate processes and redirect stdin/stdout to use a named pipe ("x>name_pipe" and "y <name_pipe"). *In either case, the open3 call uses

>
> > a "sh -c" to execute the command. *The pid that is returned is the pid
> > of the shell command and when I attempt to terminate the process only
> > the shell command is killed, not the children.

>
> > I suspect the answer is to modify the stdin/stdout file handles as
> > needed and pass those to open3. *Is this the correct solution or is
> > there another way?

>
> > Currently, this is running on Solaris 8 & 10, sparc and Intel. *There
> > is no need for portability to windows.

>
> Since portability wouldn't be an issue, you could try a negative
> signal to target an entire process group. See perldoc -f kill or
> perldoc perlipc for details.
>
> --
> Charles DeRykus


Charles,
thank you for the input. Unfortunately I did try that and it
failed. I also tried to setup a process group using setpgrp() but I
did not get that to work correctly either. I may have being doing
something wrong so that is also a possibility.

Brad
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Interesting open3 redirection problem usenet@schweikhardt.net Perl Misc 1 01-23-2009 03:08 AM
Another newbie question re: STDERR and IPC::open3(), nowait() and zombies Dave Newberry Perl 0 10-17-2004 06:41 PM
Basic Q - Response.Redirect, all redirect to first Response.Redirect statement Sal ASP .Net Web Controls 1 05-15-2004 03:46 PM
ActiveState problem using IPC::Open3 with IO::Select J. Romano Perl Misc 0 02-10-2004 03:18 AM
using open3.rb from a thread Yuri Leikind Ruby 1 01-23-2004 05:40 PM



Advertisments