def spawn_sync_pid(self, directory): argv = [] user_shell = self.guake.settings.general.get_string("default-shell") if user_shell and os.path.exists(user_shell): argv.append(user_shell) else: try: argv.append(os.environ["SHELL"]) except KeyError: argv.append("/usr/bin/bash") login_shell = self.guake.settings.general.get_boolean( "use-login-shell") if login_shell: argv.append("--login") log.debug('Spawn command: "%s"', " ".join(argv)) pid = self.spawn_sync( Vte.PtyFlags.DEFAULT, directory, argv, self.envv, GLib.SpawnFlags(Vte.SPAWN_NO_PARENT_ENVV | GLib.SpawnFlags.DO_NOT_REAP_CHILD), None, None, None, ) try: tuple_type = gi._gi.ResultTuple # pylint: disable=c-extension-no-member except: # pylint: disable=bare-except tuple_type = tuple if isinstance(pid, (tuple, tuple_type)): # Return a tuple in 2.91 # https://lazka.github.io/pgi-docs/Vte-2.91/classes/Terminal.html#Vte.Terminal.spawn_sync pid = pid[1] if not isinstance(pid, int): raise TypeError("pid must be an int") if libutempter is not None: libutempter.utempter_add_record(self.get_pty().get_fd(), os.uname()[1]) self.pid = pid return pid