From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: Date: Sun, 18 Sep 2005 20:40:03 -0400 From: Russ Cox To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu> Subject: Re: [9fans] rc scripting questions In-Reply-To: <432DDDF4.1000402@comtv.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <432DDDF4.1000402@comtv.ru> Topicbox-Message-UUID: 8c6be792-ead0-11e9-9d60-3106f5b1d025 > 1) Rc seems to create new processes in the same process group as itself. > So for example child process share it's environment variables with it's > parent (rc). Is it wise? Any unix like scripts need to call rfork as > their first command. Why is it so? Maybe it's a mistake, but it's the way it is. Occasionally I find it useful that I can change the environment variables in a prent from the child. > 2) I'd like to get random numbers in rc script, but awk 'BEGIN { print > rand }' allways give the same number. How can I get random numbers in rc > scripts? Depends on why you want the random numbers. Fortune is good at picking a random line from a file. awk 'BEGIN{srand(); print rand}' is a possibility though the random numbers aren't that great. > 3) Is there any concept like unix sessions in plan9? If I cpu into the > cpu server any program I've started will run until it suicide. Is it > right? What should I do to end my drawterm session? How can I kill every > process I've stated? It doesn't have to suicide. It can exit gracefully. When you close your drawterm session, rio will notice that the session has been hung up and will send hangup notes to all the windows. Unless your programs run rfork n to leave their window's note group, they should get the note. Other programs (like the plumber and upas/fs, which typically run behind rio) know it's time to exit because their i/o pipes get closed. Russ