I would have thought so, but I am not seeing it:

code snippet:

  if ((fp = popen(command, "r")) == NULL) {
    log_severe ("file pointer is null");
    return;
  }
  char path[100];
  while (fgets(path, 100, fp) != NULL)
    log_finer ("%s", path);
  log_fine ("popen errno: %i: %s", errno, strerror(errno));
  ret = pclose(fp);
  log_fine ("pclose errno: %i: %s", errno, strerror(errno));
  outValues->valueList[0].u.intVal = ret;
  log_fine ("return value: %i", ret);


Log output:

+CALL  ARFilterApiCall -- filter API ARSWIKI.ARF.PING
<ARSWIKI.ARF.PING> <FINE> ping command: /usr/sbin/ping cipher
<ARSWIKI.ARF.PING> <FINER> cipher is alive
<ARSWIKI.ARF.PING> <FINE> popen errno: 0: Error 0
<ARSWIKI.ARF.PING> <FINE> pclose errno: 10: No child processes
<ARSWIKI.ARF.PING> <FINE> return value: -1

>From ping man page:

The following exit values are returned:

0               Successful operation; the machine is alive.
non-zero    An error has occurred.  Either  a  malformed
                argument  has been specified, or the machine
                was not alive.

Not sure what I'm missing.

Axton Grams

On Feb 5, 2008 11:27 AM, Wayne Keenan <[EMAIL PROTECTED]> wrote:
> ** The pclose() function waits for the associated process to terminate and
> returns the exit status of the command
>
>
>
> On Feb 5, 2008 1:30 AM, Axton <[EMAIL PROTECTED]> wrote:
>
> > popen looks to be available on all platforms (posix compliant and
> > windows).  Windows defines the function as _popen though.
> >
> > http://msdn2.microsoft.com/en-us/library/96ayss4b(VS.80).aspx
> >
> > I wrote a filter plugin that executes ping via popen and returns the
> > output, but it provides no more functionality or simplicity than
> > running ping from a set fields process.  What I can't figure out how
> > to get is the exit code from ping when run via popen; only stdout.
> >
> > Axton Grams
> >
> >
> >
> >
> > On Feb 4, 2008 3:25 PM, William H. Will Du Chene <[EMAIL PROTECTED]>
> wrote:
> > > Either way, there was no getting around it. It's a de facto standard
> that
> > > a child process inherits the same level of permissions - and the profile
> -
> > > of whatever the parent process is. Without that behavior on the
> platform,
> > > we would really have issues.
> > >
> > > Axton made an excellent catch and I am grateful for it. Knowing that
> there
> > > are alternative functions out there which can be used is a very good
> > > thing.
> > >
> > > I didn't read the page close enough, so I am curious to know if these
> > > functions are present on all platforms. Many of the open source
> > > applications which I have had to tear apart and rewrite components of -
> > > such as HtDig - make use of popen to process the results from the sort
> > > utility that it uses.
> > >
> > > Unfortunately, implementations very here and there and this is something
> > > that I ran into when I ported the search engine over to windows.
> > >
> > >
> > > >
> > > > Basically all that says is whatever is run under popen runs as the
> > > > caller. In this case ARS, which should not have those privileges - and
> > > > if they are running as root they deserve all they get :-) Calling
> > > > something that uses popen from ARS is no better or worse than invoking
> > > > any other command with a run process.
> > > >
> > >
> > > --
> > >
> > >
> > > Will Du Chene
> > > [EMAIL PROTECTED]
> > > http://www.myspace.com/wduchene
> > >
> > >
> _______________________________________________________________________________
> > >
> > >
> > >
> > > UNSUBSCRIBE or access ARSlist Archives at www.arslist.org
> > > Platinum Sponsor: www.rmsportal.com ARSlist: "Where the Answers Are"
> > >
> >
> >
> _______________________________________________________________________________
> > UNSUBSCRIBE or access ARSlist Archives at www.arslist.org
> > Platinum Sponsor: www.rmsportal.com ARSlist: "Where the Answers Are"
> >
>
>  __Platinum Sponsor: www.rmsportal.com ARSlist: "Where the Answers Are"
> html___

_______________________________________________________________________________
UNSUBSCRIBE or access ARSlist Archives at www.arslist.org
Platinum Sponsor: www.rmsportal.com ARSlist: "Where the Answers Are"

Reply via email to