rust: Catch ioctl error when trying to cal tc.*grp functions

This commit is contained in:
Davie Li 2024-01-13 22:22:03 +01:00
parent c5662606df
commit 2bf0cff7be
Signed by: davie
GPG key ID: 29FD88532FC91BF4

10
env/rust.scm vendored
View file

@ -79,7 +79,10 @@ function."
(let* ((_ (reload-module (resolve-module '(guix scripts environment))))
(launch (@@ (guix scripts environment) launch-environment/container))
(setup-fhs (@@ (guix scripts environment) setup-fhs))
(tcgrp (tcgetpgrp (current-input-port))))
(tcgrp (catch 'system-error
;; catching ioctl for some types of prompts.
(λ () (tcgetpgrp (current-input-port)))
(const #f))))
;; during launch-environment/container does at least one fork take place,
;; for some reason when child exits this process receives SIGTTOU and
;; SIGTTIN signals which put it to wait. Looks like a side-effect of hacks
@ -105,7 +108,10 @@ function."
;; for the terminal used by input port changed after child
;; exits. That causes input/output error when we jump back to
;; the prompt.
(tcsetpgrp (current-input-port) tcgrp)
(when tcgrp
;; only setting it back when there were no ioctl error (see let*
;; form above)
(tcsetpgrp (current-input-port) tcgrp))
;; Why not?
(flush-all-ports)))))