9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Russ Cox <rsc@swtch.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu>
Subject: Re: [9fans] rc scripting questions
Date: Sun, 18 Sep 2005 20:40:03 -0400	[thread overview]
Message-ID: <ee9e417a050918174065b79215@mail.gmail.com> (raw)
In-Reply-To: <432DDDF4.1000402@comtv.ru>

> 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


      reply	other threads:[~2005-09-19  0:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-18 21:36 Victor Nazarov
2005-09-19  0:40 ` Russ Cox [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ee9e417a050918174065b79215@mail.gmail.com \
    --to=rsc@swtch.com \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).