Skip to content
Commits on Mar 26, 2011
  1. README.md

    committed Mar 26, 2011
Commits on Mar 24, 2011
  1. test: runtime configurable actions

    committed Mar 24, 2011
    Now we can test various combinations and orders of likely functions by changing the command-line parameters.
    
    Summary of following examples:
    
      To retain access to the per-user bootstrap namespace (tested by
      accessing the pasteboard with the pbpaste command), we always need
      to make a private API:
    
        Use the system daemon(3) and _vprocmgr_move_subset_to_user
    
          The system daemon(3) forces the forked process into the "root
          bootstrap namespace" where it can not access the per-user
          pasteboard service. We need to reattach to it to get access to
          the pasteboard.
    
        Use our own daemon() and _vprocmgr_detach_from_console
    
          Our own daemon() can prevent us from leaving the per-user
          bootstrap namespace, but we need to "detach" (move into the
          Background "bootstrap session") to make sure we retain access
          to the per-user bootstrap namespace after our initial session
          starter has exited (e.g. logging out of the GUI session, or
          logging out of an SSH session -- a non-"detached" process
          started as a child of either one will lose access to the
          per-user bootstrap namespace).
    
    Examples:
    
      pbpaste after system daemon(3)
      (i.e. minimal reproduction of stock tmux problem)
    
        ./test daemon=sys system=pbpaste
    
      Failure: pbpaste returns 1 -- it failed to access the pasteboard
    
      Reattaching to the per-user bootstrap namespace:
    
        ./test daemon=sys move-to-user=10.6 system=pbpaste
    
      Success: pbpaste returns 0, we see the pasteboard contents
    
      Using our own daemon():
    
        ./test daemon=ours system=pbpaste
    
      Success: pbpaste returns 0, we see the pasteboard contents.
    
      Using our own daemon() in an SSH connection that sticks around
      for a short while (long enough for pbpaste to run):
    
        cp /dev/null /tmp/f &&
        ssh localhost `pwd`/test \
          daemon=ours
          system=pbpaste 2\> /tmp/f \; sleep 1 &&
        { cat /tmp/f; tail -f /tmp/f; }
    
      Success: pbpaste returns 0, we see the pasteboard contents.
    
      Using our own daemon() in an SSH connection that exits before
      we run pbpaste:
    
        cp /dev/null /tmp/f &&
        ssh localhost `pwd`/test \
          daemon=ours \
          msg=sleeping... sleep=1 msg='done\ sleeping' \
          system=pbpaste 2\> /tmp/f &&
        { cat /tmp/f; tail -f /tmp/f; }
    
      Failure: pbpaste returns 1; When the SSH connection dies its
               children lose access to the per-user bootstrap namespace
               required to use the pasteboard.
    
      Using our own daemon() then "detaching from the console" in an SSH
      connection that exits before we run pbpaste:
    
      (Apple patched the "detach from console" into screen for Mac OS X v10.6;
       screen does not use daemon(), but using our own daemon that does
       not pull us into the root bootstrap namespace is, for our
       purposes, nearly equivalent to not using the system version.)
    
        cp /dev/null /tmp/f &&
        ssh localhost `pwd`/test \
          daemon=ours \
          detach \
          msg=sleeping... sleep=1 msg='done\ sleeping' \
          system=pbpaste 2\> /tmp/f &&
        { cat /tmp/f; tail -f /tmp/f; }
    
      Success: pbpaste return 0, we see the pasteboard contents.
    
      Using the system daemon(3), then reattaching to the per-user
      bootstrap namespace:
    
        cp /dev/null /tmp/f &&
        ssh localhost `pwd`/test \
          daemon=sys \
          move-to-user=10.6 \
          msg=sleeping... sleep=1 msg='done\ sleeping' \
          system=pbpaste 2\> /tmp/f &&
        { cat /tmp/f; tail -f /tmp/f; }
    
      Success: pbpaste return 0, we see the pasteboard contents.
Commits on Mar 21, 2011
  1. TODO: -detach +runtimeconf

    committed Mar 21, 2011
    _vprocmgr_detach_from_console does not do the same kind of work as
    _vprocmgr_move_subset_to_user.
    
    From what I can tell, it only prevents its caller (and its future(?)
    children) from losing access to the per-user bootstrap namespace
    when the process that started their (bootstrap-(?), certainly not
    Unix-) session exits.
    
    It will not do anything useful if used with the system daemon(3),
    because that daemon() will not only "detach from the console", but
    goes even further by moving to the root bootstrap namespace (which
    prevents access to the per-user bootstrap namespace). It only seems
    useful in places where the system daemon(3) is not used (screen(1)
    seems to do without daemon(3), which is why it is useful there).
    
    It works if you use it with your own custom daemon() that does not
    forcibly move the resulting process to the root bootstrap namespace,
    but it will not reattach a process to the per-user bootstrap
    namespace.
    
    So, if we use the system daemon(3) we need to reattach to the
    per-user bootstrap namespace with code similar to the 10.5 screen
    patch (_vprocmgr_move_subset_to_user). If we use a custom daemon(),
    then we use code similar to the 10.6 screen patch
    (_vprocmgr_detach_from_console).
    
    Ultimately, we need a private call if we want to ensure access to
    the pasteboard after the session-starter has exited.
    
    ----
    
    Start plans for revamping 'test', so that we can customize what it
    does at runtime (to try out different variations and orders of
    calling the various functions without editing and recompiling).
  2. wrapper: introduce and use warn()

    committed Mar 20, 2011
    This cuts out some of the repetition of stderr, "warning: ", and "\n".
    
    It also adds "fatal: " prefix to die() messages.
  3. TODO: warn()

    committed Mar 20, 2011
  4. wrapper: use uname(3) to find OS version

    committed Mar 20, 2011
    We warn if the OS is not "Darwin".
    
    Major versions prior to 10.2 are not fully decoded (we have no
    "attach" implementation for 10.4 and earlier anyway).
Commits on Mar 20, 2011
Something went wrong with that request. Please try again.