12-18-2018
Question about global environment variables & fork() exec()
Hello... And thanks in advance for any help anyone can offer me on my question! I've been doing a lot of reading to try and find my answer... But I haven't had any luck
What I'm trying to understand is where a child process inherits global environment variables from? I understand the exec() system call overwrites environment variable created by the fork()... But how does exec() cause global environment variables to be included with a newly created child process if all the environment variables are overwritten? My best guess is that global environment variables are somehow excluded from being overwritten... But I can't confirm this
Also... when does the fork() assign a PID to a child process? Before or after it copies itself into a new region of memory?
Thanks to everyone for any assistance!
Last edited by bodisha; 12-18-2018 at 04:21 PM..
10 More Discussions You Might Find Interesting
1. Programming
Hello!
I am working on a server where I should have 4 (resident)processes, one of them being "the father" of the others, so I do 3 forks. The problem that I have is that I do an accept (for sockets) in the "father" process and I want to transmit the job to one of the processes "child" with... (3 Replies)
Discussion started by: driki
3 Replies
2. UNIX for Dummies Questions & Answers
Hi!
Can someone explain me exactly this technique? Why a process (PARENT) creates a copy of itself with FORK (CHILD)? What's the reason of this behaviour? Sorry, but I cannot understand the logic behind it.
Thanks. (4 Replies)
Discussion started by: marshmallow
4 Replies
3. Solaris
Hi,
I need to find/implement an application that FTPs (puts) all new files in a certain directory to an external storage unit. This application should check for new files every 10 seconds (leaving the FTP connection open in between the 10 seconds).
The easiest way would be if there are... (2 Replies)
Discussion started by: KittyJ
2 Replies
4. Shell Programming and Scripting
I need to ssh to a remote server and run my script there. This is my script.
$ssh = "ssh username@host";
$cmd = "$ssh 'cd <my dir> && < sudo Run_exe>'";
my $pid = fork;
if ($pid == 0){
exec $cmd;
}
When I run this I get:
pccons_getchar: got r == 0 (1 Reply)
Discussion started by: looza
1 Replies
5. Solaris
Hi Guys,
My requirement is I have file called /opt/orahome/.profile in non global zone.
PATH=/usr/bin:/usr/ucb:/etc:/usr/sbin:/usr/local/bin:/usr/openwin/bin:.
export PATH
PS1="\${ORACLE_SID}:`hostname`:\$PWD$ "
export PS1
EDITOR=vi
export EDITOR
ENV=/opt/orahome/.kshrc
export ENV... (1 Reply)
Discussion started by: vijaysachin
1 Replies
6. Programming
Hello World!
I am writing code in C++ which have to launch another application X using exec().
I would like to set some limits on it using setrlimit etc...
My problem is that i don't know how to forbid using fork() and strlimit by application X.
How can i do it? (3 Replies)
Discussion started by: kzi
3 Replies
7. Programming
Hello everybody.I want to make clear that i am not going to ask from anybody to build my asignement but i have a big problem. I can't seem to find anywhere ONE good example on C about what i am trying to do:wall:.I think it is simple. All i ask is one example, even a link is fine.
So, i want to... (1 Reply)
Discussion started by: Cuervo
1 Replies
8. UNIX for Dummies Questions & Answers
What is is difference between 'fork with exec' and 'fork without exec'?
How both are related? (1 Reply)
Discussion started by: kkalyan
1 Replies
9. Shell Programming and Scripting
I have the following bash script lines in a file named test.sh.
#!/bin/bash
#
# Write Date to cron.log
#
echo "Begin SSI Load $(date +%d%b%y_%T)"
#
# Get the latest rates file for processing.
#
d=$(ls -tr /rms/data/ssi | grep -v "processed" | tail -n 1)
filename=$d
export filename... (3 Replies)
Discussion started by: ginowms
3 Replies
10. Shell Programming and Scripting
Hello.
During startup /etc/bash.bashrc.local generates some array
.....
source /.../.../system_common_general_array_env_var
.....
The file system_common_general_array_env_var contains :
LEAP_VERSION='42.3'
ARRAY_MAIN_REPO_LEAP=('zypper_local' 'openSUSE-Leap-'"$LEAP_VERSION"'-Non-Oss' ... (2 Replies)
Discussion started by: jcdole
2 Replies
LEARN ABOUT DEBIAN
envdir
envdir(8) System Manager's Manual envdir(8)
NAME
envdir - runs another program with environment modified according to files in a specified directory.
SYNOPSIS
envdir d child
DESCRIPTION
d is a single argument. child consists of one or more arguments.
envdir sets various environment variables as specified by files in the directory named d. It then runs child.
If d contains a file named s whose first line is t, envdir removes an environment variable named s if one exists, and then adds an environ-
ment variable named s with value t. The name s must not contain =. Spaces and tabs at the end of t are removed. Nulls in t are changed to
newlines in the environment variable.
If the file s is completely empty (0 bytes long), envdir removes an environment variable named s if one exists, without adding a new vari-
able.
EXIT CODES
envdir exits 111 if it has trouble reading d, if it runs out of memory for environment variables, or if it cannot run child. Otherwise its
exit code is the same as that of child.
SEE ALSO
supervise(8), svc(8), svok(8), svstat(8), svscanboot(8), svscan(8), readproctitle(8), fghack(8), pgrphack(8), multilog(8), tai64n(8),
tai64nlocal(8), setuidgid(8), envuidgid(8), softlimit(8), setlock(8)
http://cr.yp.to/daemontools.html
envdir(8)