Re: oninit -i -y from PHP - cannot detect that command have exited
Posted in 2000
Andrej Falout wrote:
> This little saga have to do with IDS (7.3 LE) oninit command, when
> executed from PHP code using exec() or system()
Running "oninit -iy" from anything is inherently implausible to my
way of thinking. What are you up to? Why would you want to create
a database instance on the fly?
It strikes me as being a fairly bad idea! At the very least, you had
better have darn good security controls on who can actually do that.
> Both exec() and system() in PHP are just like the C version of the
> function in that it executes the given command and outputs the result.
>
> Problem is, when PHP executes oninit like this, oninit runs fine, I can
> see my db space being created, but PHP just hangs there waiting for
> command to return to PHP, and it never does.
Maybe oninit looks at some environmental factors (such as "is stdin,
stdout or stderr a terminal; if so, I need to do a forking start, but
otherwise I don't")
> Everything else I run from PHP this way runs fine.
>
> It was suggested that oninit does something "naughty" that prevents PHP
> from detecting that exec() or system() have exited.
I'd hypothesize that at the point when exec or system doesn't return, it
is
because oninit has not exited. That's more likely than a breakage in
PHP.
> Maybe something like
> launching parallel threads, or something else that makes calling program
> think something is still running...?
>
> I even wrote a little shell script like this:
>
> #!/bin/sh
> export ONCONFIG=$1
> export INFORMIXSERVER=$2> echo INFORMIXSERVER is $INFORMIXSERVER
> echo ONCONFIG is $ONCONFIG
> echo running $INFORMIXDIR/bin/oninit -i -y
> $INFORMIXDIR/bin/oninit -i -y
> echo "done...Exit"
>
> and I can successfully run it on command line (Linux RedHat 6) but if I
> invoke it from PHP with exec or system, it will come to "done...Exit"
> but never return to PHP.
Try running the script with i/o redirection:
script >/dev/null < /dev/null 2>&1
Now see whether it finishes.
> No, it is not browser time out, server timeout or PHP timeout, I
> actually see "done...Exit" in my browser.
>
> Yes, I did try to put explicit "exit 99" et the end of shell script.
>
> If I run onmode -ky after oninit -i, I can exit back to PHP, but I
> cannot continue, since my engine is down. If I then try to do another
> oninit to start the engine again, I have the same problem as with oninit
> -i, PHP will not detect the script was finished.
>
> Question: does any-one know what might be the reason why oninit prevents
> system() from detecting that command exited, the moment oninit is in the
> command?
>
> Maybe a way to execute some command at the end of the shell script that
> can force the calling program to see that script have terminated?
>
> Any workarounds for this?
--
Yours,
Jonathan Leffler (Jonathan.Leffler@Informix.com) #include <disclaimer.h>
Guardian of DBD::Informix v1.00.PC1 -- http://www.perl.com/CPAN
"I don't suffer from insanity; I enjoy every minute of it!"