[comp.windows.news] Why doesn't the following simple NeWS example work?

montnaro@sprite (Skip Montanaro) (04/07/88)

Below is the transcript from a psh session. Can someone tell me what the
problem is (NeWS 1.1)?

    Welcome to NeWS Version 1.1
    /msg framebuffer /new DefaultWindow send def
    /reshapefromuser msg send
    /map msg send
    /destroy msg send
    ***ERROR*** 
    Process: 0x24FF44   Error: killprocess
    Stack:
    Executing: `killprocessgroup'
    At: {FrameEventMgr *`killprocessgroup'}
    In: {FrameEventMgr 'null' 'ne' array{2} *'if'}
    In: {DestroyFrame *DestroyClient}
    In: Reading file(?,W,R)
    *****
    psh: NeWS server disconnected

    Process PostScript finished

Thanks,

Skip Montanaro (montanaro@sprite.steinmetz.ge.com, montanaro@ge-crd.arpa)

owen@SUN.COM (Owen Densmore) (04/08/88)

    Below is the transcript from a psh session. Can someone tell me what the
    problem is (NeWS 1.1)?
    
	Welcome to NeWS Version 1.1
	/msg framebuffer /new DefaultWindow send def
	/reshapefromuser msg send
	/map msg send
	/destroy msg send
	***ERROR*** 
	Process: 0x24FF44   Error: killprocess
	Stack:
	Executing: `killprocessgroup'
	At: {FrameEventMgr *`killprocessgroup'}
	In: {FrameEventMgr 'null' 'ne' array{2} *'if'}
	In: {DestroyFrame *DestroyClient}
	In: Reading file(?,W,R)
	*****
	psh: NeWS server disconnected
    
	Process PostScript finished
    
    Thanks,
    
    Skip Montanaro (montanaro@sprite.steinmetz.ge.com, montanaro@ge-crd.arpa)

The problem is that the /destroy message executes a "killprocessgroup",
in which the psh is a member.  The message is innocous, but you can
avoid it by either subclassing the window to have the /destroy method
be a no-op, or you can launch the window in it's own processgroup.
Here's the former:

	/MyWindow DefaultWindow []
	classbegin
	    /destroy {/unmap self send} def
	classend def
	
	/msg framebuffer /new MyWindow send def
	/reshapefromuser msg send
	/map msg send
	/destroy msg send

[Note: I do a unmap so that the window will disappear rather than
waiting for garbage collection to take place when I re-define "msg".]

I also find it convenienent to launch windows, and simple clients, from a
psh.  My solution is a somewhat odd "runprogram" procedure which executes
a string as a psh script:

    /runprogram { % string => - (exececute the string as a psh program)
	(/tmp/pshscript) (w) file		% str file
	dup 3 -1 roll			% file file str
	writestring closefile		% -
	(psh /tmp/pshscript) forkunix
    } def

This survives the standard destroy just fine and really acts just like
a client:

	(
	    /msg framebuffer /new DefaultWindow send def
	    /reshapefromuser msg send
	    /map msg send
	) runprogram

..this window can be destroyed (zap menu) without the earlier message.
(You might have /msg put in system dict so that you can use it from
another interactive psh)

Owen Densmore
Sun Microsystems

mh@wlbr.EATON.COM (Mike Hoegeman) (04/12/88)

In article <10292@steinmetz.steinmetz.ge.com> montnaro@sprite.steinmetz.ge.com (Skip Montanaro) writes:
>
>Below is the transcript from a psh session. Can someone tell me what the
>problem is (NeWS 1.1)?
>
>    Welcome to NeWS Version 1.1
>    /msg framebuffer /new DefaultWindow send def
>    /reshapefromuser msg send
>    /map msg send
>    /destroy msg send
>    ***ERROR*** 
>    Process: 0x24FF44   Error: killprocess
>    Stack:
>    Executing: `killprocessgroup'
>    At: {FrameEventMgr *`killprocessgroup'}
>    In: {FrameEventMgr 'null' 'ne' array{2} *'if'}
>    In: {DestroyFrame *DestroyClient}
>    In: Reading file(?,W,R)
>    *****
>    psh: NeWS server disconnected
>
>    Process PostScript finished


Off-hand i think it's your destroy. when you do a /destroy method
on a litewindow it kill's all processes in it's processgroup this
includes the psh you are typing in!. to avoid this do something like this...


{
	 %% fire us up a new process group so when we destroy we don't 
	 %% zap the psh we are in along with the window

	 newprocessgroup

     /msg framebuffer /new DefaultWindow send def

	 %% modify litewin's /destroy method a bit..
	 {
			%% we gotta do this or we'll leave dangling canvases
			%% when we destroy!
			/destroy { 
				/unmap self send /destroy super send 
			} def
	 } msg send

     /reshapefromuser msg send
     /map msg send
     /destroy msg send

} fork

either that or override the destroy method in litewindow w/ a subclass
that does something a little less brutal.