~emersion/mrsh-dev

Development discussion for mrsh.

You can setup your Git repository like so:

git config sendemail.to ~emersion/mrsh-dev@lists.sr.ht
1

Issues with job control and nested shell processes

Details
Message ID
<BULBW8WJ5VD0.38N6DGWH9KX7H@homura>
Sender timestamp
1559689813
DKIM signature
pass
Download raw message
I attempted to implement $!, which expands to the pid of the most
recently backgrounded process, but I found that the process in the
processes array is a mrsh process, which is the parent of the actual
child process. The bottom pid is not available as far as I can tell.

dash:

	$ pstree -a 29479
	dash
	  └─sleep 30

mrsh:

	$ pstree -a 29047
	mrsh
	  └─mrsh
	      └─sleep 30

Even with pipelines, dash doesn't spawn itself. It only spawns itself
when executing with a subshell, as far as I can tell.
Details
Message ID
<SM6Wtca1ijR1dhg2WSHXqbl9ikilSB9lvhB0C2yyR8qePg_MvK2P-J_CIoGQQkYiDuh1a_VJoeJOqOJ-Av5T4Q6BSWH43XkeNy4GQ0ZxFBI=@emersion.fr>
In-Reply-To
<BULBW8WJ5VD0.38N6DGWH9KX7H@homura> (view parent)
Sender timestamp
1559712060
DKIM signature
pass
Download raw message
On Wednesday, June 5, 2019 2:10 AM, Drew DeVault <sir@cmpwn.com> wrote:
> I attempted to implement $!, which expands to the pid of the most
> recently backgrounded process, but I found that the process in the
> processes array is a mrsh process, which is the parent of the actual
> child process. The bottom pid is not available as far as I can tell.
>
> dash:
>
> $ pstree -a 29479
> dash
> └─sleep 30
>
> mrsh:
>
> $ pstree -a 29047
> mrsh
> └─mrsh
>   └─sleep 30
>
> Even with pipelines, dash doesn't spawn itself. It only spawns itself
> when executing with a subshell, as far as I can tell.

Hmm, which command did you run? Tried both running sleep directly and
in a pipeline, and I can't reproduce:

> pstree -a 2453
mrsh
  └─sleep 30
> pstree -a 2453
mrsh
  ├─cat
  └─sleep 30