this is what i understand from your mail.
you need your main code to keep running, while servicing I/O from the netstat FH (or
for that
matter, any FH).
Michael has already suggested pre packaged options, that should be able to help you
out.
however if you want to roll out your own code available options are
1) use a separate thread/process blocked on select.
2) a) use asynchronous I/O (signal driven) (SIGPOLL or SIGIO for SYSV or BSD)
the handler could just set a flag, and the main loop (if there is any) could
check and
read data from the filehandle. if that is the case set the FH to non/blocking.
b) if you want to transfer the data from the handler itself, use the barest
minimum code
in the handler and block the signal, when handling the shared data
structure from the
main loop.
the drawback in the second option is that there is only one signal per
process. so
the OS cannot indicate which FH is ready to be read/written. however most
modern
signal facilities in *nix pass extra information about the signals. read up on
sigaction
in the solaris manuals to see if there is some other information passed to you
process.
another problem is if perl on your box, supports SIGPOLL.
/kk
On Thu, Jun 28, 2001 at 10:51:33PM -0400, Ronald J. Yacketta wrote:
> I have heard doing it this way will cause grief.. need blocking i/o or
> something
> along that lines. Also, I head that the flow of the program would _stop_
> when reading the data...
>
> are there any other solutions?
>
> Ron
>
> P.S.
> kk, I never did get you example code working under Solaris, it works fine
> under Linux
>
>
> > -----Original Message-----
> > From: David M. Lloyd [mailto:[EMAIL PROTECTED]]
> > Sent: June 28, 2001 09:55
> > To: Ronald J. Yacketta
> > Cc: Perl
> > Subject: Re: background processing (again?)
> >
> >
> > On Thu, 28 Jun 2001, Ronald J. Yacketta wrote:
> >
> > > Folks,
> > >
> > > to make a long story short I have a req to-do the following. 1) gather
> > > continues data from netstat -I hme0 $SLEEPTIME > $netstatTMPFILE &
> > > while still parsing other information/data etc..
> > >
> > > that is, the script needs to be bale to collect the netstat data while
> > > it is running other process, not just fork netstat and wait for it to
> > > die/return. it will never die/return unless it is killed.
> >
> > Try something like this:
> >
> > open NETSTAT, "netstat -I hme0 $SLEEPTIME |" or die "Can't start
> > netstat: $!\n";
> >
> > Then, just read from the NETSTAT file handle.
> >
> > For more information, look at 'open' and 'sysopen' in the Camel book.
> > Also, you may want to consider using 'select' if you don't want to block
> > on reads. (Be sure you look at the 'ready file descriptors' version of
> > 'select').
> >
> >
> > - D
> >
> > <[EMAIL PROTECTED]>
> >
> >