On Thursday, Nov 27, 2003, at 17:49 US/Pacific, John W. Krahn wrote:
Philipp Traeder wrote:
[..]
If I am not mistaken, this is more or less exactly what I am doing right
now - the only problem I have got with this is that the user is
interrupted in his work when the 'long_action' finishes - like this:


        myshell> long_action
        initiating lengthy action...done.

now the user gets the focus back (which was the main reason behind this
exercise), and types a new command


myshell> some other command with some pa

In this very moment the long_action ends and prints

'long_action' has finished processing

As you can see, the user has been interrupted in the middle of typing
his statement, and it looks to him as if he would have lost his prompt.
My initial reaction (as a user) to this behaviour would be to press
enter - in this case the semi-complete command is executed because
$term->readline is still reading keyboard input...

Probably the best way to do it (the way the Unix shell does it for mail notification) is to output the message only when the user presses the "Enter" key. You could send a signal to the child when it is OK to print the message or send the message to the parent and let it print it at the appropriate time.


volks,

let us step back a moment and think a bit about
the problem here.

IF one does not re-direct STDOUT of the long_action
then it will be going back to the cmd line, and as
Philipp has noted, it can blurt out while the user
is typing, since his 'key strokes' are being 'echoed'
back to him from the shell.

There is a Trade off here that has to be made,
IF the primate is not to be startled by unexpected
output, then one must collect that and show it to
the primate BEFORE showing them the next prompt
but after the current command has run.

This of course will mean that one SHOULD be using
IO::Select, cf pod, as One REALLY does not want to
be doing all of the bit twiddling on their own,
TRUST ME on that.

demonstration code is available at:
<http://www.wetware.com/drieux/pbl/Sys/gen_sym_big_dog.txt>

a demonstration run is of the form:

[jeeves: 91:] perl gen_sym_big_dog.txt
Your Question: long_action 5
sending long action for 5 seconds
Your Question: long_action 6
sending long action for 6 seconds
Your Question: children
14795 in state: 1280
14796 in state: A
total of 2 sub processes
#----
Process 14795 exited with 5
        process 14795 said:
        14795 is out and running
        14795 is finished and about to exit
#----
Your Question:
#----
Process 14796 exited with 6
        process 14796 said:
        14796 is out and running
        14796 is finished and about to exit
#----
Your Question:  q
[jeeves: 92:]

the "blank" "Your Question:" section up there is
where I merely pressed a carriage return, to go back
through the main loop.

HTH.

ciao
drieux



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to