[comp.sources.d] Naval Observatory time program - utc

dag@esleng.uucp (David A. Gilmour) (01/17/91)

I recently received a program called utc from the net that allows a Unix
machine to automatically call the Naval Observatory to obtain the current
time and update the system clock.

The instructions suggest performing a cu command to connect with the
observatory and piping the output into utc.

However, when I do this, one of the cu processes stays alive and has to
be killed manually after utc completes.  The instructions say:

"You may have to fix your cu to die properly when it receives a SIGPIPE."

Can anyone tell my how I can fix cu?

Thanks in advance.


__________________________________________________________________________
David A. Gilmour            |   
Excalibur Systems Limited   |   uunet!mitel!cunews!micor!esleng!dag
Kanata, Ontario, Canada     |
-- 
__________________________________________________________________________
David A. Gilmour            |   
Excalibur Systems Limited   |   uunet!mitel!cunews!micor!esleng!dag
Kanata, Ontario, Canada     |

bruce@balilly.UUCP (Bruce Lilly) (01/19/91)

In article <1991Jan16.230534.27011@esleng.uucp> dag@esleng.uucp (David A. Gilmour) writes:
>I recently received a program called utc from the net that allows a Unix
>machine to automatically call the Naval Observatory to obtain the current
>time and update the system clock.
>
>The instructions suggest performing a cu command to connect with the
>observatory and piping the output into utc.
>
>However, when I do this, one of the cu processes stays alive and has to
>be killed manually after utc completes.  The instructions say:
>
>"You may have to fix your cu to die properly when it receives a SIGPIPE."
>
>Can anyone tell my how I can fix cu?

I use something like:
	(sleep 80 ; echo ~.) | cu 12026530351 | utc -sp

This sends a "~." to cu after 80 seconds, which causes cu to close the
connection.  You may need to change the sleep duration to suit your
modem and local phone exchange delays.

--
	Bruce Lilly		blilly!balilly!bruce@sonyd1.Broadcast.Sony.COM

bill@franklin.com (Bill) (01/20/91)

If you want utc to hang up the phone by killing cu, stick the
following at the end of utc:

	sig = signal(SIGTERM, SIG_IGN);
	kill(-getpgrp(), SIGTERM);
	signal(SIGTERM, sig);

You will have to make sure that the pipeline is not running with
the process group of its invoker, unless you want to kill the
invoker as well. Calling it from cron works fine.