Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 11/08/85; site unccvax.unccvax.UUCP Path: utzoo!watmath!clyde!burl!ulysses!bellcore!decvax!ittatc!dcdwest!sdcsvax!ncr-sd!ncrcae!ncsu!mcnc!unccvax!fpt From: fpt@unccvax.UUCP (fred p toth) Newsgroups: net.unix-wizards Subject: Re: UNIX per-process accounting Message-ID: <494@unccvax.unccvax.UUCP> Date: Tue, 15-Apr-86 22:40:26 EST Article-I.D.: unccvax.494 Posted: Tue Apr 15 22:40:26 1986 Date-Received: Fri, 18-Apr-86 20:29:23 EST References: <2570@brl-smoke.ARPA> Organization: UNC-Charlotte Lines: 45 > I've got it (I think): > > Assuming you can/will set the group of the directory to something > indicative of which customer is involved (say, their name), you could > create a .cshrc alias for 'cd' which will grovel out the group name > (this could be done most easily by writing a little C program which > just does a stat on the target, looks up the group name and prints it > to the standard output so it can be used in a backquote arg, or you > ... > -Barry Shein, Boston University Great idea Barry! In fact, I went down this almost exact trail for a while before it blew up in my face. There are 2 problems: 1. shell scripts. Process number 1 charges fine, since it appears properly in the window between cd's. However, by the time process 2 starts, the user will probably have changed directories. The rest of the script charges to the wrong job. 2. The same problem applies to any program that spawns processes, such as simple programs that use system(), or popen(). I think that this problem is solvable, but only by sacrificing much of the simplicity of your original idea. For example, there is a seldom used csh feature that could help. If you have an alias for 'shell', when the csh detects a shell script (non-exec-able but with x bits set), it prepends the value of the alias to the command. So, what you get when you type 'do_stuff.sh', is maybe 'special_program do_stuff.sh'. What the special program could do is a setregid() to establish a special group id to be inherited by the shell script that is about to run. Then you have 2 types of accounting. 1) Normal processes that fall within normal cd's. 2) Processes with special group id's that override their window position. Still have to do something with those programs that like to do system(). See how messy it gets? Still, it's great to see your ideas. If you have more, bring 'em on. Fred Toth Washburn Graphics Charlotte, NC decvax!mcnc!unccvax!wgivax!fpt