[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon Jul 20 11:37:48 2003 
Subject:Re: poplog interactive mode - PS 
From:ug57dsm 
Volume-ID:1030720.03 

Roger Evans wrote:
> Well, its amazing what actually having the code can do....
> 
> the problem is what we thought it was, but pop doesn't implement it the 
> way I said (and I remember falling over this one before...). It is true 
> that pop exits on errors if the input isn't a terminal (which is what we 
> thought), but it doesn't do this by redefining *interrupt*, it does it 
> inside *setpop*. When setpop is called it tests standard input and if 
> its not a terminal it exits. So no amount of redefining interrupt to be 
> setpop will help. BUT setpop has this funny flag pop_first_setpop, which 
> disables this behaviour the first time its called. Lukcily for us, we 
> can set this flag ourselves and so fool setpop.
> 
> So do this:
> 
>        define interrupt();
>            true -> pop_first_setpop;
>            setpop();
>        enddefine;
> 
> and you will find that mishaps get handled without exiting. (but it 
> still won't save you if someone explicitly calls setpop)
> 
> Roger
> 
> [snip]

Thanks, Roger, this does seem to work as expected. At this point I'm 
already developing the 'proper' version of the plugin, but as it 
requires a significant ammount of setup at this point (still no plugin 
but it requires the JEdit libraries) I will still use the primitive 
console for illustration purposes.

I have just come across a couple of peculiarities I'm hoping someone 
will know a workaround for:

First, look at this session:

PROBLEM 1
===========================================================
;;; do the setup as per roger's instructions
define interrupt(); true->pop_first_setpop;setpop();enddefine;

;;; throw a mishap and check it still works afterwards
x + ;;; DECLARING VARIABLE x
1;

;;; MISHAP - NUMBER(S) NEEDED
;;; INVOLVING:  <undef x> 1
;;; DOING    :  + pop_setpop_compiler
[still works?]=>
** [still works ?]

;;; Try an escaped list
[%for i from 0 to ;;; DECLARING VARIABLE i
10 do i; endfor;%]=>
** [0 1 2 3 4 5 6 7 8 9 10]

;;; and trying the same but with '[' and '%' in
;;; different lines will dump me to csh... but why?
[
%
Warning: no access to tty (Bad file descriptor).
Thus no job control in this shell.
destruktor poplog/old_tests> ps -A
   PID TTY          TIME CMD
     1 ?        00:00:04 init
     2 ?        00:00:00 keventd
     3 ?        00:00:00 kapmd
...
destruktor poplog/old_tests> exit
destruktor poplog/old_tests> exit
]=>
** []
===========================================================

That is the weirdest thing I have come across... I have no Idea why 
pop11 would escape into csh when I'm inside a list (note csh is not my 
default shell either), but it seems to be a pop11 built-in and might be 
useful (Even I can see how it would be) if slightly confusing. I was 
thinking that it probably isn't the expected behaviour for the 
application I'm writing, so I was wondering if there is a flag I can 
send to make it stop at user's request (attach action to a button or 
something).

Also try the following:

PROBLEM 2
===========================================================
;;; another list that breaks in a slightly different way
[%
for i from 1 to ;;; DECLARING VARIABLE i
10 do i; endfor;
%]=>
Missing name for redirect.
[does it work?]=>
===========================================================

Not much seems to have an effect after that happens. When I check 'ps 
-A' after multipe tests of this kind I find a lot of 'active' csh 
processes left over from the pop11 run. (Shouldn't poplog kill any 
external processes it starts when it exits?)

[dsm@destruktor:~]$ ps -A | grep csh
  2087 pts/0    00:00:00 csh
  2155 pts/0    00:07:32 csh
  2198 pts/0    00:06:08 csh
  2245 pts/0    00:01:41 csh
  2403 pts/0    00:00:02 csh

Also the csh processes take over my cpu: check what top tells me:

  11:52am  up  1:02,  3 users,  load average: 4.21, 4.12, 3.08
104 processes: 98 sleeping, 6 running, 0 zombie, 0 stopped
CPU states: 59.7% user, 40.2% system,  0.0% nice,  0.0% idle
Mem:   126288K av,  120152K used,    6136K free,       0K shrd,    7800K 
buff
Swap:  265032K av,   46584K used,  218448K free                   34428K 
cached

   PID USER     PRI  NI  SIZE  RSS SHARE STAT %CPU %MEM   TIME COMMAND
  2155 dsm        0   0  1404 1404   804 R    23.9  1.1   9:20 csh
  2198 dsm        0   0  1404 1404   804 R    23.9  1.1   7:56 csh
  2245 dsm        0   0   872  632   280 R    23.0  0.5   3:30 csh
  2403 dsm        0   0  1404 1404   804 R    23.0  1.1   1:51 csh
  1180 dsm       19   0  2380 1020   628 S     2.0  0.8   1:14 kdeinit
...

NOTE: I have noticed that pop11 doesn't quite die, it just stops 
printing anything taht happens with a few exceptions, namely: '%' still 
escapes you to a shell, and ;;; DECLARING VARIABLE xyz is still printed, 
but =>, ==>, pr() and nl() don't produce anything. also mishaps aren't 
displayed any more, even after calling interrupt() (with Roger's 
definition). The same behaviour is observed in the interactive shell:

[dsm@destruktor:~]$ pop11

Sussex Poplog (Version 15.53 Wed Apr 16 13:11:34 GMT 2003)
Copyright (c) 1982-1999 University of Sussex. All rights reserved.

Setpop
: [%
: for i from 1 to 10 do i; endfor;
 ;;; DECLARING VARIABLE i
: %]=>
 Missing name for redirect.
: [some]=>
:
: fg + 1;
 ;;; DECLARING VARIABLE fg
: []=>
: setpop();
: []=>
:

I have observed that the pop11 process will come back to normal after 
sending Ctrl+D, or in the java version by making it throw a 'missing 
semicolon' mishap, but this is far from an ideal situation (if this 
happens there are no csh leftovers). I think is has something to do with 
'%' being in the first column (i.e. calling csh) and the '>' symbol 
which has special meaning (redirect stdout) for csh, but how this 
affects pop11 after csh exits is beyond me.

And finally:

PROBLEM 3
===========================================================
;;; something else that doesn't work
true -> popnewline;

;;; MISHAP - mei: MISPLACED EXPRESSION ITEM
;;; INVOLVING:  FOUND
;;;  READING TO <termin>
;;; DOING    :  pop_setpop_compiler
===========================================================

I came across this final bit while reading the setpop(), interrupt() and 
related help/teach/ref documents. I am not entirely sure if it /should/ 
work in the first place (or completely sure of what the flag does), but 
I would like to know why that happens.

PROBLEM 1 might not really be a problem, and I could live with it if no 
solution is found, 2 is the most urgent as most people define escaped 
lists with the brackets in a different line from the lvars declarations, 
for, while or whatever they put in it. PROBLEM 3 is just a bump I came 
across. nothing urgent or important and unlikely to be used by anyone 
anyway, but I would like to know whats going on.

NOTE: Problems 1 and 2 are only relevant when '%' is the first char in 
the line, if there are spaces or other chars the list is escaped as 
expected:

[
     %
         for i from 1 to 10 do i; endfor;
     %
]
=>
** [1 2 3 4 5 6 7 8 9 10]

Again, the problem is not with '%' escaping to a system shell per-se, 
but only when it does it whilst inside a list (when it should be 
interpreted as list escape, not escape poplog)

I hope to have a working version of the plugin before the new academic 
year starts :)

Thanks for being patient enough to read all this rant.

david.

-- 
=================================================
  The future of HTML mail is clearly > /dev/null.
=================================================
  Two of the most famous products of Berkeley are
LSD and Unix. I don t think that is a coincidence
=================================================