Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site phoenix.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxl!ihnp4!phoenix!sherm From: sherm@phoenix.UUCP (Paul A. Sherman) Newsgroups: net.unix-wizards,net.lang.c Subject: Re: USG 5.0 r2: can my program tell if it is in background/nohup'd? Message-ID: <833@phoenix.UUCP> Date: Fri, 10-Aug-84 09:58:33 EDT Article-I.D.: phoenix.833 Posted: Fri Aug 10 09:58:33 1984 Date-Received: Sat, 11-Aug-84 00:30:10 EDT References: <522@burl.UUCP> Organization: AT&T Information Systems, Lincroft NJ Lines: 22 > Is there any way for me to make some test and see if I am running in > the background? I have an assembler package that calls m4(1), runs > my own yacc/lex preprocessor, passes pseudocode onto a meta-assembler, > and conditionally calls a linkage editor. I catch SIGINT because I > need to do tempfile cleanup, but when this package is run nohup'd in > the background and the user hits a delete or break in his login shell, > the interrupt punches through nohup (nohup does nothing with signal 2) > and kills the nohup'd process!! Although nohup doesn't do anything with signal 2, putting something in the background with "&" normally ignores it. You are causing it not to be ignored when you call your own routine to handle SIGINT. What you should do is check to see if SIGINT was already being ignored when you try to handle it. (This indicates that you're in the background.) If it was being ignored, reset it to that state. if (signal(SIGINT, clean_routine) == SIG_IGN) signal(SIGINT, SIG_IGN); Paul Sherman AT&T Information Systems, Lincroft, NJ phoenix!sherm --