Mac split working directory no create good working directory

Bug #1281572 reported by colombiman
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Terminator
Triaged
Wishlist
Unassigned

Bug Description

Hi,

My installation :
mac port
fink
xcode5
x11(xquartz 2.7.5)
mac os x lion moutain

I install terminator with fink.

When i execute terminator in my terminal.app, it's run x11 and def xterm in terminal default for terminator.
When i go to a random directory and press cltr+shift+e, terminator create a new terminal but in my home directory, no the working directory.
I search solution for behavior of xterm, but find nothing to "open tab/split in same working directory".

i have the same behavior if i run a terminal in x11 and run terminator.

In attach file you have :
macport installation
fink installed
terminator with -d
terminator config

for install fink and terminator i use :
#install fink and update
#
sudo fink selfupdate-rsync
sudo fink index -f
sudo fink scanpackages
sudo fink install terminator

and configure fink to use unstable packages

Best regards.

Revision history for this message
colombiman (colombiman) wrote :
Revision history for this message
colombiman (colombiman) wrote :

hi,

i think i find bug.

in debug mode you see that :
noclass::get_pid_cwd: Unable to determine a get_pid_cwd for OS: Darwin
Terminator::attempt_gnome_client: GNOME session support not available

So no cwd load, so it's not possible to get or set no original cwd.

I search, and find that cwd is pwd in mac system.

I think just change cwd to pwd and the bug fix.

I will try that.

Revision history for this message
colombiman (colombiman) wrote :

i add this condition to cwd.py in function get_pid_cwd():

 elif system == 'Darwin': #mac os
        dbg('Using Darwin get_pid_cwd but pwd')
        func = lambda pid: os.path.realpath('/proc/%s/pwd' % pid)

but i don't have ubuntu, so i don't really undestand this line '/proc/%s/cwd'

That i know that pwd, is on /bin/pwd on my mac and i have no /proc folder.

There are not more bug when i add this line, but not the good behavior.

Revision history for this message
colombiman (colombiman) wrote :

if find this :
for obtain pid of application
ps -A | grep -m1 firefox | awk '{print $1}'
get path working directory :
sof -a -p 47625 -d cwd -Fn

Revision history for this message
colombiman (colombiman) wrote :

lsof -a -p 47625 -d cwd -Fn

Revision history for this message
Stephen Boddy (stephen-j-boddy) wrote :

I took a look at the source. As I said, I don't have a Mac, so no way to check myself, but I think I can see why it doesn't work.

You have correctly identified the terminatorlib/cwd.py as the root of the problem, as there is no mention of MacOS. As a result Terminator is not able to figure out the cwd of the passed PID (i.e. bash). I certainly don't know enough about Python on MacOS to blindly fix this. Hopefully someone else (you? :-) can figure out the correct way and contribute a complete fix back.

From comment #3 the /proc filesystem does not exist in MacOS, so you can't use that command. (On a side note if you do arrive at a sane solution I'd prefer it not to involve lambda's :-) Please break it out into a separate function called darwin_get_pid_cwd, mainly because it makes things more readable and consistent with the existing code.) For your info: the /proc/<pid>/cwd is a symbolic link to the cwd of the process, and the os.path.realpath function resolves this.

From comment #4 the pid that is passed to this function is not the pid of the application, but the pid of the command running in the vte (normally the bash process, but can be something else).

Running the external lsof command is not very elegant, and you would have to take care to check the output is sane. At least here on Ubuntu your command outputs:
    $ lsof -a -p pid -d cwd -Fn
    p<pid>
    n/home/<username>
So you'd have to parse that, be sure to check you've read the correct line, that the path makes sense etc. Perhaps there is another more Pythonic method that doesn't involve launching external tools, and parsing output? I did find one project called psutil that abstracts away process handling when I was looking at another bug. However I'm not sure if I want to add this as an additional dependency, especially as it is not pure Python, and a recent version is required for MacOS support as well. You can find it at http://code.google.com/p/psutil/

Changed in terminator:
status: New → Triaged
importance: Undecided → Wishlist
Revision history for this message
colombiman (colombiman) wrote :

Hi,

I need help to upgrade setup.py of trunk for install and update terminator.
In fink there are 0.96.

i try this :

elif 'Darwin' : #mac os x with frink installation
  man_dir = '/sw/share/man'
  shareicon_dir = '/sw/share/icons/hicolor'
  sitepackages_dir = '/sw/lib/python2.6/site-packages' #terminatorlib
  doc_dir = '/sw/share/doc'
  bin_dir = '/sw/bin' #terminator and reminator
  application_dir = '/sw/share/applications #terminator.desktop

i don't know where or if po folder are installed.

but i think it's not the good way.
Directory of install is sw inded of root.

For psutil, yes it's not pure python, but Python/C API still a good c++/python wrapper.

Revision history for this message
colombiman (colombiman) wrote :

Hi,
 The solution is just --prefix=sw in setup.py install command

Bash script for auto upgrade for mac and fink install of terminator
#bin/sh
echo ' begin install terminator'

echo 'fink path'
. /sw/bin/init.sh

echo ' try build terminator'
cd ~/MesDepots/terminator/terminator0.97/
./setup.py install --prefix=sw --record=./scriptsMacUser/install-files.txt
echo 'fin install terminator'

i will try integrate psutil with bug #<1261293> solution and good pip installation

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Related questions

Remote bug watches

Bug watches keep track of this bug in other bug trackers.