develooper Front page | perl.beginners | Postings from March 2002

Re: nice, perl, fork and exec

Thread Previous
Jonathan E. Paton
March 19, 2002 10:28
Re: nice, perl, fork and exec
Message ID:
> If I run a perl script with nice, (in Unix
> it reprioritizes the process), and fork in
> perl and run an exec "command" with the
> child, does the nice priority apply to 
> he child process also? and what about the
> exec of the child process does it apply
> there too?


Whenever you launch a child process, the child
has the same permissions as the parent had/has.

For fork:

I know, that on Linux for the first time through
the child shares the same timeslot with its
parent.  I don't know, however, if that also
applies to the next timeslots - it may be
platform dependent.

For exec:

The process information (e.g. timeslot) applies
as it did to the original.

> While we are on the subject, what about system()
> and/or `` (backticks)?

system/`` creates a child process which Perl
carefully arranges behind the scenes.  Perl blocks
on these anyway whilst waiting for data, so you
are unlikely to need to worry too much here.

> man nice didn't give me any information about
> child processes.

man evil ;-)

> This is probably a perlcore developer type
> question huh?

Not really, Perl implements stuff pretty much
the way the C people do - who use libraries
that show much of Unix's nasty guts in the APIs

>  Or more likely a unix admin type question?


> If so anyone know of a good unix mail list?

Have a wonder around:

you may find something on this topic, if all
else fails look for the glibc book (older book)
which has the C interface for fork/exec etc.

Of course, you can check (and I recommend you
do :) that I'm correct by doing something like:

#!/usr/bin/perl -w
exec 'perl SLEEP' unless @ARGV;
sleep 120; # Sleep 2 minutes

and starting it off with nice, then use ps.

Jonathan Paton

Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About