bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Forcing builtins (interactive, non-interactive shells) to execute in


From: Matthew Giassa
Subject: RE: Forcing builtins (interactive, non-interactive shells) to execute in fork()'ed process.
Date: Wed, 26 Oct 2016 17:40:49 -0700
User-agent: Workspace Webmail 6.5.3

I figured it out. Turns out PS1 wasn't set. Interesting how this impacts
interactive process fork behavior (maybe it runs some things the way
non-interactive processes would normally be launched)?

============================================================
Matthew Giassa, MASc, BASc, EIT
Security and Embedded Systems Specialist
linkedin: https://ca.linkedin.com/in/giassa
e-mail:   address@hidden
website:  www.giassa.net

> -------- Original Message --------
> Subject: Forcing builtins (interactive, non-interactive shells) to
> execute in fork()'ed process.
> From: "Matthew Giassa" <address@hidden>
> Date: Wed, October 26, 2016 3:00 pm
> To: address@hidden
> Cc: address@hidden
> 
> 
> I'm doing some testing with an on-screen colorizer library I wrote,
> which does
> some PTY manipulation, captures screen output, and renders certain regex
> patterns in certain colors. It's designed to help testers notice certain
> keywords in a test environment that is not easily automated.
> 
> On bash 4.3.36 on Ubuntu 16.04 LTS, I've noticed that all commands seem
> to
> fork() a separate process, even shell builtins. This makes it easy to
> detect
> the start of any command by hooking fork() in libc. However, on bash
> 4.3.11 on
> Ubuntu 14.04 LTS, this behavior is not observed (ie: only "disk
> commands" cause
> a fork(), while builtins do not trigger a fork). Additionally, when
> running in a
> non-interactive bash instance, shell builtins never cause a fork,
> regardless of
> whether I'm running a script (ie: ./test.sh), or using bash via the "-c"
> option
> (ie: bash -c "ls; ls -la").
> 
> Is there any way, either via environment variables, BASHRC settings, or
> bash
> startup flags, or some other means (ie: not recompiling bash) where I
> can:
> 
> 1) Have bash 4.3.11 fork() for every interactive command, like in bash
> 4.3.36.
> 2) Have both bash 4.3.11 and 4.3.36 trigger a fork() for builtins being
> executed
> in a non-interactive shell?
> 
> I could potentially use PROMPT_COMMAND to detect the most recent
> command, "type"
> it, and force running in a subshell, but I want to avoid breaking other
> scripts
> by changing how commands are actually executed, save for forking.
> 
> On a side note, its interesting how bash 4.3.36 does this, even for the
> "cd"
> command, since launching it in a subshell can't change the CWD for the
> parent
> process.
> 
> Thank you.
> 
> 
> 
> ============================================================
> Matthew Giassa, MASc, BASc, EIT
> Security and Embedded Systems Specialist
> e-mail:   address@hidden
> website:  www.giassa.net



reply via email to

[Prev in Thread] Current Thread [Next in Thread]