[vte] pty: Add more error checking
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte] pty: Add more error checking
- Date: Sat, 12 Oct 2019 18:12:35 +0000 (UTC)
commit 3b695af9524cc76bdf4ab77ba1e4f0d7963a2852
Author: Christian Persch <chpe src gnome org>
Date: Sat Oct 12 20:10:55 2019 +0200
pty: Add more error checking
src/pty.cc | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
---
diff --git a/src/pty.cc b/src/pty.cc
index 637acae1..372c1cf6 100644
--- a/src/pty.cc
+++ b/src/pty.cc
@@ -104,7 +104,7 @@ Pty::child_setup() const noexcept
sigset_t set;
sigemptyset(&set);
if (pthread_sigmask(SIG_SETMASK, &set, nullptr) == -1) {
- _vte_debug_print(VTE_DEBUG_PTY, "Failed to unblock signals: %m");
+ _vte_debug_print(VTE_DEBUG_PTY, "%s failed: %m\n", "pthread_sigmask");
_exit(127);
}
@@ -122,12 +122,12 @@ Pty::child_setup() const noexcept
_exit(127);
if (grantpt(masterfd) != 0) {
- _vte_debug_print(VTE_DEBUG_PTY, "%s failed: %m", "grantpt");
+ _vte_debug_print(VTE_DEBUG_PTY, "%s failed: %m\n", "grantpt");
_exit(127);
}
if (unlockpt(masterfd) != 0) {
- _vte_debug_print(VTE_DEBUG_PTY, "%s failed: %m", "unlockpt");
+ _vte_debug_print(VTE_DEBUG_PTY, "%s failed: %m\n", "unlockpt");
_exit(127);
}
@@ -137,8 +137,15 @@ Pty::child_setup() const noexcept
* This also loses the controlling TTY.
*/
_vte_debug_print (VTE_DEBUG_PTY, "Starting new session\n");
- setsid();
- setpgid(0, 0);
+ if (setsid() == -1) {
+ _vte_debug_print(VTE_DEBUG_PTY, "%s failed: %m\n", "setsid");
+ _exit(127);
+ }
+
+ if (setpgid(0, 0) == -1) {
+ _vte_debug_print(VTE_DEBUG_PTY, "%s failed: %m\n", "setpgid");
+ /* _exit(127); */
+ }
}
#endif
@@ -185,7 +192,10 @@ Pty::child_setup() const noexcept
#ifdef TIOCSCTTY
if (!(m_flags & VTE_PTY_NO_CTTY)) {
- ioctl(fd, TIOCSCTTY, fd);
+ if (ioctl(fd, TIOCSCTTY, fd) != 0) {
+ _vte_debug_print(VTE_DEBUG_PTY, "%s failed: %m\n", "ioctl(TIOCSCTTY)");
+ _exit(127);
+ }
}
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]