[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Forcing builtins (interactive, non-interactive shells) to execute in
RE: Forcing builtins (interactive, non-interactive shells) to execute in fork()'ed process.
Wed, 26 Oct 2016 17:40:49 -0700
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
> -------- 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
> fork() a separate process, even shell builtins. This makes it easy to
> 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"
> (ie: bash -c "ls; ls -la").
> Is there any way, either via environment variables, BASHRC settings, or
> startup flags, or some other means (ie: not recompiling bash) where I
> 1) Have bash 4.3.11 fork() for every interactive command, like in bash
> 2) Have both bash 4.3.11 and 4.3.36 trigger a fork() for builtins being
> 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
> 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
> command, since launching it in a subshell can't change the CWD for the
> Thank you.
> Matthew Giassa, MASc, BASc, EIT
> Security and Embedded Systems Specialist
> e-mail: address@hidden
> website: www.giassa.net
- RE: Forcing builtins (interactive, non-interactive shells) to execute in fork()'ed process.,
Matthew Giassa <=