gnome-terminal r3288 - trunk/src
- From: chpe svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-terminal r3288 - trunk/src
- Date: Tue, 27 Jan 2009 20:28:21 +0000 (UTC)
Author: chpe
Date: Tue Jan 27 20:28:21 2009
New Revision: 3288
URL: http://svn.gnome.org/viewvc/gnome-terminal?rev=3288&view=rev
Log:
Use the current directory of the foreground process, not the
child_pid's.
Modified:
trunk/src/terminal-screen.c
Modified: trunk/src/terminal-screen.c
==============================================================================
--- trunk/src/terminal-screen.c (original)
+++ trunk/src/terminal-screen.c Tue Jan 27 20:28:21 2009
@@ -69,6 +69,7 @@
char **override_command;
char *working_dir;
int child_pid;
+ int pty_fd;
double font_scale;
guint recheck_working_dir_idle;
gboolean user_title; /* title was manually set */
@@ -349,6 +350,7 @@
if (priv->working_dir == NULL) /* shouldn't ever happen */
priv->working_dir = g_strdup (g_get_home_dir ());
priv->child_pid = -1;
+ priv->pty_fd = -1;
priv->recheck_working_dir_idle = 0;
@@ -1485,6 +1487,7 @@
terminal_screen_launch_child (TerminalScreen *screen)
{
TerminalScreenPrivate *priv = screen->priv;
+ VteTerminal *terminal = VTE_TERMINAL (screen);
TerminalProfile *profile;
char **env, **argv;
char *path;
@@ -1505,7 +1508,7 @@
update_records = terminal_profile_get_property_boolean (profile, TERMINAL_PROFILE_UPDATE_RECORDS);
- priv->child_pid = vte_terminal_fork_command (VTE_TERMINAL (screen),
+ priv->child_pid = vte_terminal_fork_command (terminal,
path,
argv,
env,
@@ -1521,6 +1524,8 @@
"%s", _("There was an error creating the child process for this terminal"));
}
+ priv->pty_fd = vte_terminal_get_pty (terminal);
+
g_free (path);
g_strfreev (argv);
g_strfreev (env);
@@ -1746,7 +1751,7 @@
g_return_val_if_fail (TERMINAL_IS_SCREEN (screen), NULL);
/* Try to update the working dir using various OS-specific mechanisms */
- if (priv->child_pid >= 0)
+ if (priv->pty_fd >= 0)
{
static const char *patterns[] = {
"/proc/%d/cwd", /* Linux */
@@ -1756,13 +1761,18 @@
char buf[PATH_MAX+1];
int len = 0;
guint i;
+ int fgpid;
+
+ fgpid = tcgetpgrp (priv->pty_fd);
+ if (fgpid == -1)
+ return priv->working_dir; /* FIXME set priv->working_dir to NULL? */
/* First try to update the working dir using various OS-specific mechanisms */
file = NULL;
for (i = 0; i < G_N_ELEMENTS (patterns); ++i)
{
g_free (file);
- file = g_strdup_printf (patterns[i], priv->child_pid);
+ file = g_strdup_printf (patterns[i], fgpid);
len = readlink (file, buf, sizeof (buf) - 1);
if (len > 0 && buf[0] == '/')
@@ -1896,6 +1906,7 @@
/* No need to chain up to VteTerminalClass::child_exited since it's NULL */
priv->child_pid = -1;
+ priv->pty_fd = -1;
action = terminal_profile_get_property_enum (priv->profile, TERMINAL_PROFILE_EXIT_ACTION);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]