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

add --passive option for backgrounding #25

Merged
merged 3 commits into from
Jan 31, 2013
Merged

Conversation

FND
Copy link
Contributor

@FND FND commented Jan 23, 2013

It appears rerun doesn't like to be backgrounded:

$ bundle exec rerun "bundle exec ruby app.rb" &
[rerun] App launched
stty: standard input: Inappropriate ioctl for device
stty: standard input: Inappropriate ioctl for device
stty: standard input: Inappropriate ioctl for device
stty: standard input: Inappropriate ioctl for device
<ad infinitum>

Presumably that's happening within the key_pressed method when attempting to read STDIN.

Thus this new --passive option* disables the on-the-fly commands entirely.

* not sure whether -b is a good short variant, but -p was taken

@alexch
Copy link
Owner

alexch commented Jan 23, 2013

Maybe --background would be a better name, then?

Good catch. btw on OS X i get somewhat different (still broken) backgrounding behavior from the unpatched version: it immediately pauses, then foregrounding shows stty: tcsetattr: Interrupted system call

@FND
Copy link
Contributor Author

FND commented Jan 23, 2013

--background was my first thought as well, but that seemed misleading as it suggests automatic backgrounding/daemonization.

(I should have mentioned I'm on Arch Linux and Ruby 1.9.3)

@alexch
Copy link
Owner

alexch commented Jan 23, 2013

Yeah, good point. There's a similar terminological knot around the --exit (-x) option -- it doesn't make rerun exit, it makes it expect that its target program will exit.

Maybe --no-input?

Hopefully I'll be more clever after a cup of coffee.

@FND
Copy link
Contributor Author

FND commented Jan 23, 2013

I suppose --no-input would work - not sure if it's less confusing than --passive, but in the end, anyone who looks for this probably already knows why they need it.

@alexch
Copy link
Owner

alexch commented Jan 23, 2013

--deaf ?
--no-listen ?

@FND
Copy link
Contributor Author

FND commented Jan 24, 2013

Since we're clearly having trouble describing this option, here's another thought: Auto-detect whether the process was backgrounded.

Not sure how that could be done - but perhaps there's some check on $stdin we could perform?

@alexch
Copy link
Owner

alexch commented Jan 24, 2013

http://www.unixguide.net/unix/faq/3.7.shtml

I think I have tty-detecting code in Wrong somewhere...

@alexch
Copy link
Owner

alexch commented Jan 24, 2013

Hmph. On OS X, in a backgrounded process, STDIN.tty? returns true. Back to
the drawing board...

@FND
Copy link
Contributor Author

FND commented Jan 25, 2013

Same on my Linux machine, which kinda makes sense because it's still attached to the terminal - what we want is to determine whether we're running interactively, which I haven't found a solution for yet.

@alexch
Copy link
Owner

alexch commented Jan 25, 2013

I looked into Highline, which reportedly [1] was the cleanest way to do this, and found that a recent commit [2] inadvertently removed the feature [3].

[1] http://stackoverflow.com/questions/174933/how-to-get-a-single-character-without-pressing-enter/3983726#3983726
[2] JEG2/highline@2abb2c7#lib/highline/system_extensions.rb
[3] JEG2/highline#50

@envygeeks
Copy link

I kinda need this in a sorts, when I open up a Pry session in the middle of a live HTTP session the polling for c, r and other friends makes it impossible to work with Pry (not to mention the fact that I can't use c and r without the system assuming I want to restart,) so much so I had to program my own watcher even though I would rather work with Rerun because it probably thinks about stuff I don't care about (I just kill everything and restart it.)

Just an option to entirely disable the c, r and other polling would suffice to making this happy, edit: or... maybe you could do like Guard did and integrate with Pry (not saying it's a great idea but who wouldn't love a side debugger to test things out quickly) and just make c, r and others commands inside of Pry.

@jipiboily
Copy link

👍

I started to use rerun in a proof of concept project and it works great but I feel the same pain as @envygeeks. Is there a chance that this will be merged at some point (no rush, I can use the fork for now)? 😄

@alexch
Copy link
Owner

alexch commented Jan 31, 2013

Yeah, I'll take care of it today.

alexch added a commit that referenced this pull request Jan 31, 2013
add --passive option for backgrounding
@alexch alexch merged commit 317c7c9 into alexch:master Jan 31, 2013
@alexch
Copy link
Owner

alexch commented Jan 31, 2013

I think I will go back to --background. To my ear, it doesn't sound like it implies automatic daemonization... that would be --daemonize or some such. And it makes -b make more sense :-)

@FND
Copy link
Contributor Author

FND commented Jan 31, 2013

Sounds good - done > perfect etc.

@jipiboily
Copy link

Didn't want to rush you, but thanks! :)

👍

@alexch
Copy link
Owner

alexch commented Jan 31, 2013

It was my pleasure. I've been learning iOS and working in Ruby for a few hours was a welcome relief. I'll push it as soon as RubyGems.org is back online (see http://news.ycombinator.com/item?id=5139583 ).

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.

4 participants