Closed xyb3rt closed 1 year ago
Is this ok with you, @rakitzis?
This looks good. How about an update to trip.rc
to cover the change?
I've moved the call to clearflow()
directly into rc_fork()
. Shouldn't this be done to all the calls to setsigdefaults(FALSE)
too, @rakitzis? There's only one call to rc_fork()
in backq()
where the child does not call it and I'm not sure if this omission was done intentionally.
This may indeed be an oversight. It may be easy to test the backq
use case since setsigdefaults
clears sigexit
, so there is a deterministic way to provoke bad behavior.
So it's really not obvious, but I traced this down.. may be worth documenting in backq after calling fork(): since the backquoted command is invoked by exec(), and since exec() calls setsigdefaults, restoring signals is not needed in the setup after fork().
It also seems like setsigdefaults is called redundantly in many cases. In fact, perhaps in all the cases excluding backq!
The logic here is quite twisted. I can't say I'm proud of it 30 years on. I would leave it alone, as a real fix may involve keeping track of some sort of state which needs to be applied after fork() and before exec(). Doing this via a collection of booleans sprinkled through the code is very brittle.
Fixes issue #68.