From: A.Heskett@bnr.co.uk (Tony Heskett)
Newsgroups: comp.databases.informix
Subject: Re: Interrupt Message
Date: 13 Aug 92 12:18:03 GMT
Reply-To: A.Heskett@bnr.co.uk (Tony Heskett)
X-Informix-List-ID: <list.1375>


Since no-one else seems to have bitten yet ...

Richard Ridley writes:

> A background process will be started up by a particular user when running
> an application - this background process will monitor a direcory and,
> whenever a new file is copied into the directory, will inform the user
> (either using a tty or the login name) that a new file has been placed
> into the directory.

If you use a windowing system, or allow a number of users to use
the same login, you gotta be quite careful that you get the *right* tty.

> [ ... write(1) is messy ... ]

> What we would like to be able to do is to interrupt whatever the user is doing
> place the message in the middle of the screen (possibly in a box or after
> clearing the screen), wait for a key to be pressed after the message has
> been read, redraw the screen and let the user continue whatever he/she
> was doing.

If you do that, you have a number of problems:

*   The original app is likely to be reading from the tty.
    Your 'Got-a-new-file' display will also be reading from the
    tty, to get the ACK from the user.   It's a toss-up who gets
    the chars the user types.   Confusion reigns.

    P'raps 'kill -STOP old-app-pid', then the message, then
    'kill -CONT old-app-pid'   ?    Arrghh  :-)

*   The screen handling stuff (approximately curses) built into Informix
    relies knowing what the screen looks like.   If you write on
    the screen, the app's memory image doesn't match the screen
    and all subsequent display is corrupted.

    You can get round this by redisplaying the screen, but this 
    has to be a user action ([s]he presses the 'Redisplay' key).
    Don't believe you'll be able to signal the original app to
    redisplay the screen.

*   The screen modes have to be saved and restored either side
    of your message.

> Alternatively, we could have a status line either on the top or the bottom
> of the screen and display the messages there - would this be possible and

If you've got 25-line terminals, and the Informix (JYACC JAM ?) screens
only use 24 lines and ignore the 25th (it's managed separately from the
other 24), you shouldn't have a  problem with doing it that way.
Just write on the 25th line.   Mind you, you still can't get chars
back from the user ...

> if so, could it be terminal-type independent?

If you use the status line approach, you're relying on a particular
manufacturer's feature, so no.    It's easy to draw boxes in a 
terminal-independent manner, but I don't see how you can read 
the keyboard or redraw the screen satisfactorily afterwards.

If you've got source for the app, can you just add a function
to do a readdir(3V) and a couple of stat(2V)s to see if
things have changed  ?  Use the normal Informix stuff to 
pop up a prompt window and call the function on a reasonably 
regular basis (e.g. once whenever a new screen is displayed).

> Thanks in advance,
>
> Richard Ridley

Don't suppose that helps any, sorry 'bout that.  Any better ideas out there ?

Your normal programming will now be resumed.

Cheers - Tony.

PS.  Nip down to Rowans for a couple of Grolsches for me, would ya ?  Ta.
_________________________________________________________________________
Tony Heskett                 th@bnr.co.uk       Phone: (+44) 279 402637
BNR, London Road, Harlow, Essex  CM17 9NA       Fax:   (+44) 279 451434