def list_processes(options)
  		if options[:exe]
  			name = options[:exe].sub(/.*\/(.*)/, '\1')
  			if RUBY_PLATFORM =~ /linux/
  				ps = "ps -C '#{name}'"
  			else
  				ps = "ps -A"
  				options[:match] = Regexp.new(Regexp.escape(name))
  			end
  		elsif options[:name]
  			if RUBY_PLATFORM =~ /linux/
  				ps = "ps -C '#{options[:name]}'"
  			else
  				ps = "ps -A"
  				options[:match] = Regexp.new(" #{Regexp.escape(options[:name])}")
  			end
  		elsif options[:match]
  			ps = "ps -A"
  		else
  			raise ArgumentError, "Invalid options."
  		end

  		processes = []
  		case RUBY_PLATFORM
  		when /solaris/
  			list = `#{ps} -o pid,ppid,nlwp,vsz,rss,comm`.split("\n")
  			threads_known = true
  		when /darwin/
  			list = `#{ps} -w -o pid,ppid,vsz,rss,command`.split("\n")
  			threads_known = false
  		else
  			list = `#{ps} -w -o pid,ppid,nlwp,vsz,rss,command`.split("\n")
  			threads_known = true
  		end
  		list.shift
  		list.each do |line|
  			line.gsub!(/^ */, '')
  			line.gsub!(/ *$/, '')

  			p = Process.new
  			if threads_known
  				p.pid, p.ppid, p.threads, p.vm_size, p.rss, p.name = line.split(/ +/, 6)
  			else
  				p.pid, p.ppid, p.vm_size, p.rss, p.name = line.split(/ +/, 5)
  				p.threads = "?"
  			end
  			p.name.sub!(/\Aruby: /, '')
  			p.name.sub!(/ \(ruby\)\Z/, '')
  			if p.name !~ /^ps/ && (!options[:match] || p.name.match(options[:match]))
  				# Convert some values to integer.
  				[:pid, :ppid, :vm_size, :rss].each do |attr|
  					p.send("#{attr}=", p.send(attr).to_i)
  				end
  				p.threads = p.threads.to_i if threads_known

  				if platform_provides_private_dirty_rss_information?
  					p.private_dirty_rss = determine_private_dirty_rss(p.pid)
  				end
  				processes << p
  			end
  		end
  		return processes
  	end
def list_processes(options)
  		if options[:exe]
  			name = options[:exe].sub(/.*\/(.*)/, '\1')
  			if RUBY_PLATFORM =~ /linux/
  				ps = "ps -C '#{name}'"
  			else
  				ps = "ps -A"
  				options[:match] = Regexp.new(Regexp.escape(name))
  			end
  		elsif options[:name]
  			if RUBY_PLATFORM =~ /linux/
  				ps = "ps -C '#{options[:name]}'"
  			else
  				ps = "ps -A"
  				options[:match] = Regexp.new(" #{Regexp.escape(options[:name])}")
  			end
  		elsif options[:match]
  			ps = "ps -A"
  		else
  			raise ArgumentError, "Invalid options."
  		end

  		processes = []
  		case RUBY_PLATFORM
  		when /solaris/
  			list = `#{ps} -o pid,ppid,nlwp,vsz,rss,comm`.split("\n")
  			threads_known = true
  		when /darwin/
  			list = `#{ps} -w -o pid,ppid,vsz,rss,command`.split("\n")
  			threads_known = false
  		else
  			list = `#{ps} -w -o pid,ppid,nlwp,vsz,rss,command`.split("\n")
  			threads_known = true
  		end
  		list.shift
  		list.each do |line|
  			line.gsub!(/^ */, '')
  			line.gsub!(/ *$/, '')

  			p = Process.new
  			if threads_known
  				p.pid, p.ppid, p.threads, p.vm_size, p.rss, p.name = line.split(/ +/, 6)
  			else
  				p.pid, p.ppid, p.vm_size, p.rss, p.name = line.split(/ +/, 5)
  				p.threads = "?"
  			end
  			p.name.sub!(/\Aruby: /, '')
  			p.name.sub!(/ \(ruby\)\Z/, '')
  			if p.name !~ /^ps/ && (!options[:match] || p.name.match(options[:match]))
  				# Convert some values to integer.
  				[:pid, :ppid, :vm_size, :rss].each do |attr|
  					p.send("#{attr}=", p.send(attr).to_i)
  				end
  				p.threads = p.threads.to_i if threads_known

  				if platform_provides_private_dirty_rss_information?
  					p.private_dirty_rss = determine_private_dirty_rss(p.pid)
  				end
  				processes << p
  			end
  		end
  		return processes
  	end
Returns a list of Process objects that match the given search criteria.

  # Search by executable path.
  list_processes(:exe => '/usr/sbin/apache2')

  # Search by executable name.
  list_processes(:name => 'ruby1.8')

  # Search by process name.
  list_processes(:match => 'Passenger FrameworkSpawner')