PEEL(3R)

NAME
peel - make process local and create new process

SYNOPSIS
#include <dmd.h>

Proc *peel (dstrect, flag)
Rectangle dstrect;
int flag;

DESCRIPTION

The peel function is an uncommon feature that allows a process to be made local and reshaped (or moved). The peel function then creates a new process that uses the previous process's window and host connection. The rectangle dstrect defines the new window (display) to be used by the peeled local process. The remaining window is associated with a new process that takes on the status of the connection of the previous process.

If argument flag is zero, the terminal's default process is started in the old window. If argument flag has a non-zero value, the process that is used to replace the peeled process is another invocation of the same process. The process must be cached to do this.

The peeled process will have its P->state variable updated. If the dstrect rectangle is the same size as the original window, both the MOVED and RESHAPED bits will be set; otherwise, just the RESHAPED bit is set. If the MOVED bit is set, the new window will have the contents of the old window copied into it. Otherwise, it is the responsibility of the peeled process to draw the new window's contents. The old window is always cleared.

The function will return -1 if it failed due to a lack of memory. It will return 0 if it failed because dstrect is smaller than 32x32. Otherwise, it will return a pointer to the newly created process running in the old window.

EXAMPLE

The following example shows how a process can peel itself and leave behind the default terminal process. The rectangle dstrect is specified through the mouse interface that allows the user to position or sweep out a rectangle using a default size as specified by the rectangle of the window or a new size using the mouse and button 2.

    #include <dmd.h>
    Proc *peel();
    Rectangle newrect();
    int
    peelme()
    {
       Proc *p;
       p = peel(newrect(2, display.rect), 0);
       if(p == (Proc *)-1)
          msgbox("no memory", (char *)0);
       else if(p == (Proc *)0)
          msgbox("swept window too small", (char *)0);
       return((long)p > 0);
    }

SEE ALSO
cache(3L), local(3R), state(3R).