Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!usc!elroy.jpl.nasa.gov!decwrl!sgi!shinobu!odin!sundiver.esd.sgi.com!chawley From: chawley@sundiver.esd.sgi.com (Christopher J. Hawley) Newsgroups: comp.sys.sgi Subject: Re: TRAPPING SIGNALS IN CSH Keywords: onintr Message-ID: <1991Apr25.181843.10764@odin.corp.sgi.com> Date: 25 Apr 91 18:18:43 GMT References: <9104242103.AA11863@ccfiris.aedc> Sender: news@odin.corp.sgi.com (Net News) Reply-To: chawley@sundiver.esd.sgi.com Organization: Silicon Graphics Inc. / Personal Systems Division Lines: 60 In article <9104242103.AA11863@ccfiris.aedc>, mcdonald@AEDC-VAX.AF.MIL writes: |> My problem arises when the user hits Ctrl-C when he first logs |> in which kills the execution of /etc/cshrc, thus my expiration checker does |> not get executed. How can I trap these signals in a csh? Read the description of the csh builtin command "onintr" in csh(1) . It provides a barely adequate (IMHO) means of intercepting interrupt signals; used in conjunction with some stty(1) contortions to disable other signals from the keyboard, you could write something similar to the following: ... # Assume we're executing from a tty. # Save tty settings, disable signals except for SIGINT set ottymode = `stty -g` stty quit '^-' # "undef" on some BSD systems # Trap interrupts to clean-up portion of script onintr interrupted ... ... goto finished # Clean-up handling (executed when interrupted) interrupted: ... ... # Here to complete task, restore terminal modes, return status. # Restore original tty settings stty $ottymode; unset ottymode # Revert to previous interrupt handling (if sourced inline) onintr # Exit with return status (if subshell or aborted) exit($returnstatus) |> In a Bourne shell all I have to do is trap them with the trap command. Y'know, that's probably the easiest way to accomplish the task... use an explicit invocation: /bin/sh chgpwdscript Use the trap builtin and set SHELL=/bin/sh within chgpwdscript . |> | Kenneth M. McDonald * OAO Corp * Arnold Engineering Development Center | |> | MS 120 * Arnold AFS, TN 37389-9998 * (615) 454-3413 | #include "std_disclaimer.h" /* My opinions are my own... in my opinion, standard discs are lame. */ --- Christopher J. Hawley / esper chawley@sundiver.esd.sgi.com Silicon Graphics, Inc. 1L-945 phone: 415 / 335-1621 Mountain View, CA 94039-7311 USA 408 / 243-1042 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Nicht nur wie schnell Sie fahren, sondern _wie_ Sie schnell fahren."