PHP proc_open bash vs dash

Consider this example script:

<?php

$pipes = array();
$p = proc_open('cat', array(0 => STDIN, 1 => STDOUT, 2 => STDERR), $pipes);
fgetc(STDIN);

When /bin/shsymbolically attached to /bin/dash(default Debian), it catis executed in the shell:

30760 pts/0    S+     0:00  |           \_ php f.php
30761 pts/0    S+     0:00  |               \_ sh -c cat
30762 pts/0    S+     0:00  |                   \_ cat

If /bin/shassociated with /bin/bash, however, catis a direct child of php:

30786 pts/0    S+     0:00  |           \_ php f.php
30787 pts/0    S+     0:00  |               \_ cat

This is a very annoying inconsistency, which makes it impossible to reliably send signals to the generated process (since the signal sometimes receives the signal).

Why does proc_open behave differently depending on where it points /bin/sh? Is there a way to not run the shell, even if /bin/shnot bash?

+4
source share
1 answer

PHP /bin/sh , , PHP. dash ( ) . bash execve(), cat.

, , : https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=436466

bash , PID , , .

+3

Source: https://habr.com/ru/post/1533394/


All Articles