[MacRuby] #479: Need GCD wrapper for Process Sources
#479: Need GCD wrapper for Process Sources ----------------------------------------+----------------------------------- Reporter: ernest.prabhakar@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: MacRuby 0.5 Component: MacRuby | Keywords: ----------------------------------------+----------------------------------- We should wrap DISPATCH_SOURCE_TYPE_PROC http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPag... proc_src = Dispatch::Source.for_process(queue, Process::Status, mask, &block) I think the only tricky part is defining a good set of constants for the mask: DISPATCH_PROC_EXIT The process has exited and is available to wait(2). DISPATCH_PROC_FORK The process has created one or more child processes. DISPATCH_PROC_EXEC The process has become another executable image via a call to execve(2) or posix_spawn(2). DISPATCH_PROC_REAP The process status has been collected by its parent process via wait(2). DISPATCH_PROC_SIGNAL A signal was delivered to the process. So they can be easily extracted from the data passed to the handler: The data returned by dispatch_source_get_data() indicates which of the events in the mask were observed. For example, it may be worthwhile to create a Dispatch::Source::ProcessEvent class which is passed both as the original mask and as the data returned to the handler. -- Ticket URL: <http://www.macruby.org/trac/ticket/479> MacRuby <http://macruby.org/>
#479: Need GCD wrapper for Process Sources ----------------------------------------+----------------------------------- Reporter: ernest.prabhakar@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: MacRuby 0.5 Component: MacRuby | Keywords: ----------------------------------------+----------------------------------- Comment(by ernest.prabhakar@…): I was being overly elaborate. The API should just take a PID not a Process::Status. Gotta get away from thinking in terms of static types... -- Ticket URL: <http://www.macruby.org/trac/ticket/479#comment:1> MacRuby <http://macruby.org/>
#479: Need GCD wrapper for Process Sources ----------------------------------------+----------------------------------- Reporter: ernest.prabhakar@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: MacRuby 0.5 Component: MacRuby | Keywords: ----------------------------------------+----------------------------------- Comment(by ernest.prabhakar@…): Replying to [comment:1 ernest.prabhakar@…]:
I was being overly elaborate. The API should just take a PID not a Process::Status. Gotta get away from thinking in terms of static types...
So, the revised proposal is for something like: process_mask = Dispatch::Source::ProcessEvent.new(:exit, :exec, :reap, :signal) process_mask.exit = false proc_src = Dispatch::Source.for_process(queue, pid, process_mask) do |event| if event.exec then "Do something" end -- Ticket URL: <http://www.macruby.org/trac/ticket/479#comment:2> MacRuby <http://macruby.org/>
#479: Need GCD wrapper for Process Sources ----------------------------------------+----------------------------------- Reporter: ernest.prabhakar@… | Owner: ernest.prabhakar@… Type: defect | Status: new Priority: blocker | Milestone: MacRuby 0.5 Component: MacRuby | Keywords: ----------------------------------------+----------------------------------- Changes (by ernest.prabhakar@…): * owner: lsansonetti@… => ernest.prabhakar@… -- Ticket URL: <http://www.macruby.org/trac/ticket/479#comment:3> MacRuby <http://macruby.org/>
#479: Need GCD wrapper for Process Sources ----------------------------------------+----------------------------------- Reporter: ernest.prabhakar@… | Owner: ernest.prabhakar@… Type: defect | Status: closed Priority: blocker | Milestone: MacRuby 0.5 Component: MacRuby | Resolution: fixed Keywords: | ----------------------------------------+----------------------------------- Changes (by ernest.prabhakar@…): * status: new => closed * resolution: => fixed Comment: Fixed on or before r3267 along with specs and rdoc. -- Ticket URL: <http://www.macruby.org/trac/ticket/479#comment:4> MacRuby <http://macruby.org/>
participants (1)
-
MacRuby