# calling php script from C - pclose problem

- Thread: https://externals.io/message/22674
- Original archive: https://news-web.php.net/php.internals/22674
- Started by Ysidro on 2006-04-06T00:05:34+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #22674 — Ysidro — 2006-04-06T00:05:34+00:00

URL: https://externals.io/message/22674#22674

Hello,

Posted this message on php-general@lists.php.net and only received a 
very helpful suggestion to post here, thanks in advance for any 
additional help...

Calling a php script from legacy c code using `popen()`, works great.
Problem: when php script is done, `pclose()` in c code fails with ECHILD, 
No child process, wait4() failed.

This is because the php script does not hang around to be wait'ed for; 
any idea how to make a command line php script behave like a normal 
child process that waits for its parent to get a status via a wait 
system call?

---

## #22676 — Wez Furlong — 2006-04-06T03:53:22+00:00

URL: https://externals.io/message/22674#22676 · In reply to: #22674

That doesn't sound right... it's more likely that you're doing
something funky in your process (not php) with `SIGCHLD` so that wait4()
misses the event when you pclose.

My suggestion: strace your stuff and look for rogue signal() and wait
style calls that might be screwing things up.  Third party libraries
(in particular, OCI) can have this kind of effect.

--Wez.


> Hello,
>
> Posted this message on php-general@lists.php.net and only received a
> very helpful suggestion to post here, thanks in advance for any
> additional help...
>
> Calling a php script from legacy c code using `popen()`, works great.
> Problem: when php script is done, `pclose()` in c code fails with ECHILD,
> No child process, wait4() failed.
>
> This is because the php script does not hang around to be wait'ed for;
> any idea how to make a command line php script behave like a normal
> child process that waits for its parent to get a status via a wait
> system call?
