Skip to content

Commit 2c874b3

Browse files
committed
Merge pull request resque#688 from postmodern/windows
**Always** split `command` output using $/ for Windows.
2 parents d39046f + 1cc12bb commit 2c874b3

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

examples/god/stale.god

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ STALE_EXEMPTIONS = ["imports"]
77
Thread.new do
88
loop do
99
begin
10-
lines = `ps -e -o pid,command | grep [r]esque`.split("\n")
10+
lines = `ps -e -o pid,command | grep [r]esque`.split($/)
1111
lines.each do |line|
1212
parts = line.split(' ')
1313
next if parts[-2] != "at"

lib/resque/worker.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ def worker_pids
566566
# Returns an Array of string pids of all the other workers on this
567567
# machine. Useful when pruning dead workers on startup.
568568
def windows_worker_pids
569-
`tasklist /FI "IMAGENAME eq ruby.exe" /FO list`.split("\n").select { |line| line =~ /^PID:/}.collect{ |line| line.gsub /PID:\s+/, '' }
569+
`tasklist /FI "IMAGENAME eq ruby.exe" /FO list`.split($/).select { |line| line =~ /^PID:/}.collect{ |line| line.gsub /PID:\s+/, '' }
570570
end
571571

572572
# Find Resque worker pids on Linux and OS X.
@@ -589,7 +589,7 @@ def get_worker_pids(command)
589589
active_worker_pids = []
590590
output = %x[#{command}] # output format of ps must be ^<PID> <COMMAND WITH ARGS>
591591
raise 'System call for ps command failed. Please make sure that you have a compatible ps command in the path!' unless $?.success?
592-
output.split("\n").each{|line|
592+
output.split($/).each{|line|
593593
next unless line =~ /resque/i
594594
next if line =~ /resque-web/
595595
active_worker_pids.push line.split(' ')[0]

test/test_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
exit_code = MiniTest::Unit.new.run(ARGV)
3333

34-
processes = `ps -A -o pid,command | grep [r]edis-test`.split("\n")
34+
processes = `ps -A -o pid,command | grep [r]edis-test`.split($/)
3535
pids = processes.map { |process| process.split(" ")[0] }
3636
puts "Killing test redis server..."
3737
pids.each { |pid| Process.kill("TERM", pid.to_i) }

0 commit comments

Comments
 (0)