05-05-2008
Last time I checked system() was deprecated in that it uses /bin/sh -c and is a security risk due to set(u|g)id privilege escalation and environment manipulation attacks.
There's a good case that spawning a shell to execute a command is not a good idea (as shamrock noted) if a simple exec will suffice.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I am working on HPUX11 systems.
I intend to achieve following:
Need to write a shell script that will launch a program on remote UNIX machine. It will be gr8 if in addition, the remote process can be monitored using some feedback.
I donno how to use rsh / ssh for this. (specifying... (1 Reply)
Discussion started by: mrx
1 Replies
2. Programming
Hello all -
I'm writing an app that needs to have another program running BEFORE I fire up my application.
The .exe resides on another computer - not on the computer that my app is running on. This computer is running Tru64 Digital Unix 4.0F
The application that I wrote was built using... (1 Reply)
Discussion started by: kapolani
1 Replies
3. UNIX for Dummies Questions & Answers
Hello,
I needed a help please...
I have an application which launches process. For this i am using fork and execv method calls. By doing this my launched process are now child process of the parent process(launching process). I dont want this to happen, i want the process that is launched to... (1 Reply)
Discussion started by: deepthi
1 Replies
4. UNIX for Dummies Questions & Answers
I have launched telnet on nt and have connected to a unix server,
I'm trying to run a program on the unix server which will launch a gui, but when I try to launch it
I get the message
"display not set\n"
"By default set it to 0.0"
I can sit down at the unix machine and launch the program with... (3 Replies)
Discussion started by: cbachman
3 Replies
5. UNIX for Advanced & Expert Users
Hi!
I would launch this command:
tar -cvvf logswitch.tar `find *.log* -mtime +5` --remove-files
only if
find *.log* -mtime +5
find some files.
Thanks in advance. (10 Replies)
Discussion started by: Minguccio75
10 Replies
6. UNIX for Advanced & Expert Users
Hello - I already have Veritas netbackup installed on Mac OS. But I am not able to find the daemon name for running the backup. Does anyone know How to run netbackup?
Thank you! (3 Replies)
Discussion started by: panchpan
3 Replies
7. UNIX for Dummies Questions & Answers
Hi people,
i just installed Eclipse on my Solaris terminal and i can't seem to run it. Currently i am using the SSH Client software to go to my Unix console.I tried to run the command "eclipse -vm <path of java hre>" as directed however i still can't run the application.
My Command prompt is... (5 Replies)
Discussion started by: wilsontan
5 Replies
8. Linux
Hi all,
I installed RHEL on my machine and realized that firefox browser was not
included at installation. I went back and added it using the Add or Remove
Packages by inserting the dvd I used during installation. The icon is there
but for some reason I cannot lauch. Nothing returns when I... (12 Replies)
Discussion started by: jxh461
12 Replies
9. Shell Programming and Scripting
Hi all! I just got done writing a script. The problem Im running into is I have to lanuch the script with:
sh SCRIPT.sh
Is there a way to launch it with by just entering
SCIPT
into the shell? (3 Replies)
Discussion started by: Grizzly
3 Replies
10. UNIX for Dummies Questions & Answers
Hi
I want to write a very short bash script for doing the following action (on Ubuntu):
First, install java
Second, launch at a specific time (e.g. 4.30 pm) a java ANT program.
How can I do this? (3 Replies)
Discussion started by: Helveticus
3 Replies
FORK(2) BSD System Calls Manual FORK(2)
NAME
fork -- create a new process
SYNOPSIS
#include <unistd.h>
pid_t
fork(void);
DESCRIPTION
Fork() causes creation of a new process. The new process (child process) is an exact copy of the calling process (parent process) except for
the following:
o The child process has a unique process ID.
o The child process has a different parent process ID (i.e., the process ID of the parent process).
o The child process has its own copy of the parent's descriptors. These descriptors reference the same underlying objects, so that,
for instance, file pointers in file objects are shared between the child and the parent, so that an lseek(2) on a descriptor in the
child process can affect a subsequent read or write by the parent. This descriptor copying is also used by the shell to establish
standard input and output for newly created processes as well as to set up pipes.
o The child processes resource utilizations are set to 0; see setrlimit(2).
RETURN VALUES
Upon successful completion, fork() returns a value of 0 to the child process and returns the process ID of the child process to the parent
process. Otherwise, a value of -1 is returned to the parent process, no child process is created, and the global variable errno is set to
indicate the error.
ERRORS
Fork() will fail and no child process will be created if:
[EAGAIN] The system-imposed limit on the total number of processes under execution would be exceeded. This limit is configuration-
dependent.
[EAGAIN] The system-imposed limit MAXUPRC (<sys/param.h>) on the total number of processes under execution by a single user would
be exceeded.
[ENOMEM] There is insufficient swap space for the new process.
LEGACY SYNOPSIS
#include <sys/types.h>
#include <unistd.h>
The include file <sys/types.h> is necessary.
SEE ALSO
execve(2), sigaction(2), wait(2), compat(5)
HISTORY
A fork() function call appeared in Version 6 AT&T UNIX.
CAVEATS
There are limits to what you can do in the child process. To be totally safe you should restrict yourself to only executing async-signal
safe operations until such time as one of the exec functions is called. All APIs, including global data symbols, in any framework or library
should be assumed to be unsafe after a fork() unless explicitly documented to be safe or async-signal safe. If you need to use these frame-
works in the child process, you must exec. In this situation it is reasonable to exec yourself.
4th Berkeley Distribution June 4, 1993 4th Berkeley Distribution