9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] rc scripting questions
@ 2005-09-18 21:36 Victor Nazarov
  2005-09-19  0:40 ` Russ Cox
  0 siblings, 1 reply; 2+ messages in thread
From: Victor Nazarov @ 2005-09-18 21:36 UTC (permalink / raw)
  To: 9fans

Hello.

I use plan9 with drawterm under ms windows. I know the system very 
partial. So I'd like to ask some questions about rc scripting.

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?

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?

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?

--
Victor Nazarov
http://vir.comtv.ru/
vir@comtv.ru



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [9fans] rc scripting questions
  2005-09-18 21:36 [9fans] rc scripting questions Victor Nazarov
@ 2005-09-19  0:40 ` Russ Cox
  0 siblings, 0 replies; 2+ messages in thread
From: Russ Cox @ 2005-09-19  0:40 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> 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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-09-19  0:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-18 21:36 [9fans] rc scripting questions Victor Nazarov
2005-09-19  0:40 ` Russ Cox

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).