diff --git a/plugins/terminal/gb-terminal-view.c b/plugins/terminal/gb-terminal-view.c
index 62b08ec..4ed547e 100644
--- a/plugins/terminal/gb-terminal-view.c
+++ b/plugins/terminal/gb-terminal-view.c
@@ -24,6 +24,7 @@
 #include <glib/gi18n.h>
 #include <ide.h>
 #include <stdlib.h>
+#include <sys/ioctl.h>
 #include <vte/vte.h>
 #include <unistd.h>
 
@@ -270,6 +271,8 @@ gb_terminal_respawn (GbTerminalView *self,
   if (-1 == (tty_fd = open (name, O_RDWR | O_CLOEXEC)))
     IDE_GOTO (failure);
 
+  ioctl (tty_fd, TIOCSCTTY, tty_fd);
+
   /* dup() is safe as it will inherit O_CLOEXEC */
   if (-1 == (stdout_fd = dup (tty_fd)) || -1 == (stderr_fd = dup (tty_fd)))
     IDE_GOTO (failure);
