9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] handling notes
@ 2006-10-11  3:30 Joel “chesky” Salomon
  2006-10-11  4:35 ` Russ Cox
  0 siblings, 1 reply; 3+ messages in thread
From: Joel “chesky” Salomon @ 2006-10-11  3:30 UTC (permalink / raw)
  To: 9fans

I'm doing an exercise for my Operating Systems class here at Cooper, and I'm supposed to be catching signals.  The professor was nice enough to let me catch notes on Plan 9 if I could make that work.

The code is at <http://www.tip9ug/who/chesky/src/katp.c> and <http://www.tip9ug/who/chesky/src/wdp.c>.  Basically, katp installs a note handler with atnotify then spawns a pager to catenate its command-line aguments to.  Wdp, the World’s Dumbest Pager, reads a single ½KB chunk from stdin then closes it and exits.

Eventually, katp is supposed to recognize that the pipe is closed and respawn wdp; I’m not there yet.  Right now, I can’t get the note handler to print anything on pipe close.  If I add a sleep(long time) somewhere and interrupt it, the handler reports it; just not for the closed pipe.

What am I missing or doing wrong?

Thanks,
--Joel



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [9fans] handling notes
  2006-10-11  3:30 [9fans] handling notes Joel “chesky” Salomon
@ 2006-10-11  4:35 ` Russ Cox
  2006-10-11  7:52   ` Joel “chesky” Salomon
  0 siblings, 1 reply; 3+ messages in thread
From: Russ Cox @ 2006-10-11  4:35 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Try a bigger file, like /dev/zero.
Or insert a sleep(500) after the write in cat.

Why either of those would fix the problem is
an exercise to the reader.  ;-)

Russ


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [9fans] handling notes
  2006-10-11  4:35 ` Russ Cox
@ 2006-10-11  7:52   ` Joel “chesky” Salomon
  0 siblings, 0 replies; 3+ messages in thread
From: Joel “chesky” Salomon @ 2006-10-11  7:52 UTC (permalink / raw)
  To: 9fans

> Try a bigger file, like /dev/zero.
> Or insert a sleep(500) after the write in cat.
> 
> Why either of those would fix the problem is
> an exercise to the reader.  ;-)

I tried /lib/keyboard as input, and saw the breadcrumb from program end before the end of output; the parent process dies before the pipe breaks!

I’m putting the sleep(500), properly commented, (what manual section is sleep(500) in? ☺) into cat to get the same effect.  Thanks, Russ!

Now for the detection and respawning...  I’ll hold off on asking for hints for a little while and try to figure it out myself.

Good nigh— ye flipplin’ gods, it’s already morning! — folks,
--Joel



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-10-11  7:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-10-11  3:30 [9fans] handling notes Joel “chesky” Salomon
2006-10-11  4:35 ` Russ Cox
2006-10-11  7:52   ` Joel “chesky” Salomon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).