Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!att!linac!uwm.edu!cs.utexas.edu!sdd.hp.com!elroy.jpl.nasa.gov!ncar!midway!clout!chinet!les From: les@chinet.chi.il.us (Leslie Mikesell) Newsgroups: comp.unix.questions Subject: Re: How do I unset TXTBSY on a daemon's binary? Message-ID: <1991May11.213816.24934@chinet.chi.il.us> Date: 11 May 91 21:38:16 GMT References: <1991May10.042300.5901@massey.ac.nz> Organization: Chinet - Chicago Public Access UNIX Lines: 29 In article <1991May10.042300.5901@massey.ac.nz> A.Raman@massey.ac.nz (A.V.Raman) writes: >1. What is the accepted procedure to unset the TXTBSY flag on the binary > after the daemon backgrounds itself? Just mv it to a different name on the same filesystem so you can replace it with the new version. Later you can rm the old version. If the program is being frequently executed, arranging to mv the old copy to another directory that is later in the PATH of the users will insure that either the old or new copy will be executable at all times. >2. How do I find out if a particular user is logged on from within a C > program. >I need to do (2) because I want to find out whether I must write a >user or mail him regarding some status change he required. I tried doing >a man -k on "user", "wtmp", "logg" etc., but none gives me any info about >a C library function / System call that tells me whether a particular user >is logged on. If the notification is important, I'd mail it in all cases. Just being logged in does not insure that you will see a "write" message. But why not just execute write and let it fail if the user isn't logged in? You have to be prepared for failure anyway, since the user might log out between your test and the execution of write - why do you need any other test?. Les Mikesell les@chinet.chi.il.us