Skip to content

Conversation

vtjnash
Copy link
Member

@vtjnash vtjnash commented May 28, 2025

This was originally added as a workaround for the behavior of sh to try to become the terminal process group leader, but no longer relevant since #25006 removed that flag again:

julia> run(detach(`bash -i -c "sleep 0"`))
bash: cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell
Process(`bash -i -c 'sleep 0'`, ProcessExited(0))

Julia recieves SIGTTOU when a process like "sh -i -c" exits (at least for bash and zsh, but not dash, ksh, or csh), since "sh -i" sometimes takes over the controlling terminal, causing julia to stop once the bash process exits. This can be quite annoying, but julia goes through some pains (in libuv) to ensure it doesn't steal the controlling terminal from the parent, and apparently bash is not so careful about it. However, since PR #25006, julia hasn't needed this workaround for this issue, so we can now follow the intended behavior when the child is in the same session group and steals the controlling terminal from the parent. Even if such behavior seems odd, this seems to be the intended behavior per posix design implementation that it gets SIGTTOU when julia later tries to change mode (from cooked -> raw after printing the prompt): http://curiousthing.org/sigttin-sigttou-deep-dive-linux.

$ ./julia -q
shell> bash -i -c "sleep 1"

[1]+  Stopped                 ./julia

julia> run(`zsh -i -c "sleep 0"`)
Process(`zsh -i -c 'sleep 0'`, ProcessExited(0))

julia>
[1]+  Stopped                 ./julia

This was originally added as a workaround for the behavior of sh to try
to become the terminal process group leader, but no longer relevant
since #25006 removed that flag again:
```
julia> run(detach(`bash -i -c "sleep 0"`))
bash: cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell
Process(`bash -i -c 'sleep 0'`, ProcessExited(0))
```

Julia recieves SIGTTOU when a process like "sh -i -c" exits (at least
for bash and zsh, but not dash, ksh, or csh), since "sh -i" sometimes
takes over the controlling terminal, causing julia to stop once the bash
process exits. This can be quite annoying, but julia goes through some
pains (in libuv) to ensure it doesn't steal the controlling terminal
from the parent, and apparently bash is not so careful about it.
However, since PR #25006, julia hasn't needed this workaround for this
issue, so we can now follow the intended behavior when the child is in
the same session group and steals the controlling terminal from the
parent. Even if such behavior seems odd, this seems to be the intended
behavior per posix design implementation that it gets SIGTTOU when julia
later tries to change mode (from cooked -> raw after printing the
prompt): http://curiousthing.org/sigttin-sigttou-deep-dive-linux.

```
$ ./julia -q
shell> bash -i -c "sleep 1"

[1]+  Stopped                 ./julia

julia> run(`zsh -i -c "sleep 0"`)
Process(`zsh -i -c 'sleep 0'`, ProcessExited(0))

julia>
[1]+  Stopped                 ./julia
```
@vtjnash vtjnash added REPL Julia's REPL (Read Eval Print Loop) backport 1.12 Change should be backported to release-1.12 labels May 28, 2025
@vtjnash
Copy link
Member Author

vtjnash commented May 29, 2025

For background on why this is a useful signal and behavior and should not be just blocked, see nodejs/node#35536

@vtjnash
Copy link
Member Author

vtjnash commented May 29, 2025

According to glibc, there's a half page of code for how to correctly implement a REPL mode change call: https://www.gnu.org/software/libc/manual/html_node/Initializing-the-Shell.html

@vtjnash vtjnash merged commit 0cbe466 into master May 29, 2025
7 of 10 checks passed
@vtjnash vtjnash deleted the jn/repl_cmd_session branch May 29, 2025 18:35
KristofferC pushed a commit that referenced this pull request Jun 2, 2025
This was originally added as a workaround for the behavior of sh to try
to become the terminal process group leader, but no longer relevant
since #25006 removed that flag again:
```
julia> run(detach(`bash -i -c "sleep 0"`))
bash: cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell
Process(`bash -i -c 'sleep 0'`, ProcessExited(0))
```

Long explanation: Julia recieves SIGTTOU when a process like "sh -i -c"
exits (at least for bash and zsh, but not dash, ksh, or csh),
since "sh -i" sometimes takes over the controlling terminal, causing
julia to stop once the bash process exits. This can be quite annoying,
but julia goes through some pains (in libuv) to ensure it doesn't steal
the controlling terminal from the parent, and apparently bash is not so
careful about it. However, since PR #25006, julia hasn't needed this
workaround for this issue, so we can now follow the intended behavior
when the child is in the same session group and steals the controlling
terminal from the parent. Even if such behavior seems odd, this seems
to be the intended behavior per posix design implementation that it
gets SIGTTOU when julia later tries to change mode (from cooked -> raw
after printing the prompt):
http://curiousthing.org/sigttin-sigttou-deep-dive-linux.

For some background on why this is a useful signal and behavior and
should not be just blocked, see nodejs/node#35536.

According to glibc, there's a half page of code for how to correctly
implement a REPL mode change call:
https://www.gnu.org/software/libc/manual/html_node/Initializing-the-Shell.html

```
$ ./julia -q
shell> bash -i -c "sleep 1"

[1]+  Stopped                 ./julia

julia> run(`zsh -i -c "sleep 0"`)
Process(`zsh -i -c 'sleep 0'`, ProcessExited(0))

julia>
[1]+  Stopped                 ./julia
```

(cherry picked from commit 0cbe466)
@KristofferC KristofferC removed the backport 1.12 Change should be backported to release-1.12 label Jun 4, 2025
@vtjnash vtjnash added backport 1.12 Change should be backported to release-1.12 backport 1.10 Change should be backported to the 1.10 release backport 1.11 Change should be backported to release-1.11 labels Sep 4, 2025
DilumAluthge pushed a commit that referenced this pull request Sep 9, 2025
This was originally added as a workaround for the behavior of sh to try
to become the terminal process group leader, but no longer relevant
since #25006 removed that flag again:
```
julia> run(detach(`bash -i -c "sleep 0"`))
bash: cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell
Process(`bash -i -c 'sleep 0'`, ProcessExited(0))
```

Long explanation: Julia recieves SIGTTOU when a process like "sh -i -c"
exits (at least for bash and zsh, but not dash, ksh, or csh),
since "sh -i" sometimes takes over the controlling terminal, causing
julia to stop once the bash process exits. This can be quite annoying,
but julia goes through some pains (in libuv) to ensure it doesn't steal
the controlling terminal from the parent, and apparently bash is not so
careful about it. However, since PR #25006, julia hasn't needed this
workaround for this issue, so we can now follow the intended behavior
when the child is in the same session group and steals the controlling
terminal from the parent. Even if such behavior seems odd, this seems
to be the intended behavior per posix design implementation that it
gets SIGTTOU when julia later tries to change mode (from cooked -> raw
after printing the prompt):
http://curiousthing.org/sigttin-sigttou-deep-dive-linux.

For some background on why this is a useful signal and behavior and
should not be just blocked, see nodejs/node#35536.

According to glibc, there's a half page of code for how to correctly
implement a REPL mode change call:
https://www.gnu.org/software/libc/manual/html_node/Initializing-the-Shell.html

```
$ ./julia -q
shell> bash -i -c "sleep 1"

[1]+  Stopped                 ./julia

julia> run(`zsh -i -c "sleep 0"`)
Process(`zsh -i -c 'sleep 0'`, ProcessExited(0))

julia>
[1]+  Stopped                 ./julia
```

(cherry picked from commit 0cbe466)
@DilumAluthge DilumAluthge mentioned this pull request Sep 9, 2025
59 tasks
@DilumAluthge DilumAluthge added backport 1.11 Change should be backported to release-1.11 and removed backport 1.11 Change should be backported to release-1.11 labels Sep 9, 2025
DilumAluthge pushed a commit that referenced this pull request Sep 13, 2025
This was originally added as a workaround for the behavior of sh to try
to become the terminal process group leader, but no longer relevant
since #25006 removed that flag again:
```
julia> run(detach(`bash -i -c "sleep 0"`))
bash: cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell
Process(`bash -i -c 'sleep 0'`, ProcessExited(0))
```

Long explanation: Julia recieves SIGTTOU when a process like "sh -i -c"
exits (at least for bash and zsh, but not dash, ksh, or csh),
since "sh -i" sometimes takes over the controlling terminal, causing
julia to stop once the bash process exits. This can be quite annoying,
but julia goes through some pains (in libuv) to ensure it doesn't steal
the controlling terminal from the parent, and apparently bash is not so
careful about it. However, since PR #25006, julia hasn't needed this
workaround for this issue, so we can now follow the intended behavior
when the child is in the same session group and steals the controlling
terminal from the parent. Even if such behavior seems odd, this seems
to be the intended behavior per posix design implementation that it
gets SIGTTOU when julia later tries to change mode (from cooked -> raw
after printing the prompt):
http://curiousthing.org/sigttin-sigttou-deep-dive-linux.

For some background on why this is a useful signal and behavior and
should not be just blocked, see nodejs/node#35536.

According to glibc, there's a half page of code for how to correctly
implement a REPL mode change call:
https://www.gnu.org/software/libc/manual/html_node/Initializing-the-Shell.html

```
$ ./julia -q
shell> bash -i -c "sleep 1"

[1]+  Stopped                 ./julia

julia> run(`zsh -i -c "sleep 0"`)
Process(`zsh -i -c 'sleep 0'`, ProcessExited(0))

julia>
[1]+  Stopped                 ./julia
```

(cherry picked from commit 0cbe466)
@KristofferC KristofferC mentioned this pull request Sep 24, 2025
24 tasks
@KristofferC KristofferC removed the backport 1.12 Change should be backported to release-1.12 label Sep 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 1.10 Change should be backported to the 1.10 release backport 1.11 Change should be backported to release-1.11 REPL Julia's REPL (Read Eval Print Loop)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants