fix suspend in session master when fork_on_start #296
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
After commit b102add following request #287,
term->master
is used as test to see if this is session master process we want to wakeup with SIGCONT after suspend (master must be kept running, or other slaves will block). Test uses comparisonterm->fdout == 1
, which is never true in the case of forked master whenui.session.fork_on_start
. The forked master has different (>10) fdout descriptor numbers, so it will never beterm->master
and thusmaster_pid
will still have its initialized value 0.Instead we can get the pid directly after forking, and use the interlink creation attempt to decide whether this is a master or slave process depending on successful connect(). This was tested with both
fork_on_start=1
andfork_on_start=0
with different suspend/resume permutations and seems to work correctly now.Note that
term->master
is used in several places:exec_on_terminal()
,try_to_draw_images()
,redraw_screen()
,erase_screen()
,get_resource_info()
andget_master_session()
, so it could be thatfork_on_start
has other issues.