code: @Override
     public void registerProcess(OsxProcess process)
     {
        if (shutdown) {
           return;
        }
  
        int pid = process.getPid();
        Pointer pidPointer = Pointer.createConstant(pid);
  
        pidToProcessMap.put(pid, process);
  
        Integer stdinFd = null;
        Integer stdoutFd = null;
        Integer stderrFd = null;
        try {
           stdinFd = process.getStdin().acquire();
           stdoutFd = process.getStdout().acquire();
           stderrFd = process.getStderr().acquire();
           // We don't use the processEvents array here, since this method is not
           // called on the event processor thread.
           Kevent[] events = (Kevent[]) new Kevent().toArray(4);
           // Listen for process exit (one-shot event)
           events[0].EV_SET((long) pid, Kevent.EVFILT_PROC, Kevent.EV_ADD | Kevent.EV_RECEIPT | Kevent.EV_ONESHOT,
                            Kevent.NOTE_EXIT | Kevent.NOTE_EXITSTATUS | Kevent.NOTE_REAP, 0L, pidPointer);
           // Listen for stdout and stderr data availability (events deleted automatically when file descriptors closed)
           events[1].EV_SET(stdoutFd, Kevent.EVFILT_READ, Kevent.EV_ADD | Kevent.EV_RECEIPT, 0, 0L, pidPointer);
           events[2].EV_SET(stderrFd, Kevent.EVFILT_READ, Kevent.EV_ADD | Kevent.EV_RECEIPT, 0, 0L, pidPointer);
           // Listen for stdin data availability (initially disabled until user wants read, deleted automatically when file descriptor closed)
           events[3].EV_SET(stdinFd, Kevent.EVFILT_WRITE, Kevent.EV_ADD | Kevent.EV_DISABLE | Kevent.EV_RECEIPT, 0, 0L, pidPointer);
  
           registerEvents(events, 4);
        } finally {
           if (stdinFd != null) {
              process.getStdin().release();
           }
           if (stdoutFd != null) {
              process.getStdout().release();
           }
           if (stderrFd != null) {
              process.getStderr().release();
           }
        }
     }
docs: ************************************************************************