Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop the use of nohup on OSX for tmux compatibility #4534

Merged
merged 1 commit into from Nov 27, 2015

Conversation

mcornella
Copy link
Member

Apparently nohup is not needed in OSX, and using it has the side that it may break under tmux with the error

nohup: can't detach from console: No such file or directory

For now, this commit only drops the use of nohup in OSX. But it may not be necessary under other similar platforms.

Fixes #4520

@apjanke
Copy link
Contributor

apjanke commented Oct 21, 2015

Works more or less as expected for me on OS X 10.9.5, in and out of tmux. (That is, the file gets opened in native app per file associations, and command returns immediately.)

However, it always returns true, even when given a bad argument. I think the underlying commands all report a useful exit status; it would be nice to expose that.

[~]
$ open no-such-file.txt
The file /Users/janke/no-such-file.txt does not exist.
[✘ ~]
$ echo $?
1
[~]
$ open_command no-such-file.txt
[~]
$ echo $?
0

I don't think backgrounding or disowning the job is necessary on OS X; open uses IPC to invoke an application that's in the desktop session and is a child of launchd, and hands the file off to it. Similar with cygstart on Windows; the Windows program that it hands off to is running in the desktop session, and isn't a child of the shell or terminal. Since all these "open" commands are IPC handoff things, backgrounding or disowning might not be needed at all. And in the case where there was an error doing the handoff or resolving a program, I think you'd want that status info synchronously.

@mcornella mcornella force-pushed the fix-open_command-nohup-tmux branch 3 times, most recently from b253c5f to 1beef80 Compare November 21, 2015 02:27
Apparently `nohup` is not needed in OSX, and using it has the side
that it may break under tmux with the error

  nohup: can't detach from console: No such file or directory

For now, this commit only drops the use of `nohup` in OSX. But it
*may* not be necessary under other similar platforms.
@mcornella
Copy link
Member Author

Ok I've replaced the current solution with just droping nohup under OSX. I can't test that this works everywhere on OSX but you seem pretty confident that open doesn't need to be disowned. In fact, xdg-open in my debian system also behaves the same way, but I recall some system where calling that without nohup didn't work well.

Anyway, I'm finally merging this one.

@mcornella mcornella changed the title Use alternative to nohup for tmux compatibility Drop the use of nohup on OSX for tmux compatibility Nov 27, 2015
mcornella added a commit that referenced this pull request Nov 27, 2015
Drop the use of nohup on OSX for tmux compatibility
@mcornella mcornella merged commit d2e1c71 into ohmyzsh:master Nov 27, 2015
@mcornella mcornella deleted the fix-open_command-nohup-tmux branch November 27, 2015 14:51
nunogt pushed a commit to nunogt/oh-my-zsh that referenced this pull request Jan 25, 2016
…-tmux

Drop the use of nohup on OSX for tmux compatibility
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants