11-28-2008
This is not the place for writing homework for others!!
10 More Discussions You Might Find Interesting
1. Programming
When I compile this C programme I get different outputs each time I run it
Please explain to me whats happening in the code if you can give me a detailed explanation. Because I am stuck with this.
#include <stdio.h>
main(){
int i = 0;
printf("I am the... (1 Reply)
Discussion started by: manjuWicky
1 Replies
2. UNIX for Advanced & Expert Users
When I compile this C programme I get different outputs each time I run it
Please explain to me whats happening in the code if you can give me a detailed explanation with the schedular functionality it will help a lot. Because I am stuck with this.
#include <stdio.h>
main(){... (3 Replies)
Discussion started by: manjuWicky
3 Replies
3. Programming
Hi
I'm currently working with C on UNIX (HPUX) and need to be able to fork a seperate Java process from within a running C process.
I can run the following code from the command line via a script but am having difficulty getting it to work from within the code.
I am trying to use execl. Is... (4 Replies)
Discussion started by: themezzaman
4 Replies
4. Programming
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
int main()
{
pid_t pID;
int i;
for (i = 0; i < 3; i++)
{
pID = fork ();
if (pID == 0)
{
printf ("Value of i --> %d... (2 Replies)
Discussion started by: kymthasneem
2 Replies
5. Programming
Is it safe to call fork+exec in a multithreaded application.
Because In my multithreaded application, I need to execute another program in each thread.
I am using solaris 10.
Any suggestions pls. (2 Replies)
Discussion started by: axes
2 Replies
6. Shell Programming and Scripting
Hello,
I am new to this site, so sorry ahead of time if this is not the right place for this question.......anywhooooo
I am having troubles with forking new processes in wish. Take the following code example:
****************************
package require Tclx
puts "TCL VER: "
proc... (3 Replies)
Discussion started by: pghamami
3 Replies
7. Shell Programming and Scripting
Hi,
my $log = IO::File->new(">$log_file_name");
$log->print("date()."--\n\n\n");
sub process {
my ($sub_dir, $file, $config, $log) = @_;
$log->print("-- Reading $file file\n");
}
my $pm = new Parallel::ForkManager($tc+1);
$pm->run_on_finish( sub { my ($pid, $exit_code,... (1 Reply)
Discussion started by: sandy1028
1 Replies
8. Shell Programming and Scripting
Keep in mind that I haven't done Perl scripting for a LONG time, so I'm quite rusty.
This is what I would like to do:
- using fork, create 3 or 4 processes to read 3 or 4 different text documents containing server names or IP addresses
- in each of those processes, Perl will ping each of those... (7 Replies)
Discussion started by: kooshi
7 Replies
9. Programming
My question is, how do you fork only the parent processes in unix? For example how would I use the fork function to fork the parent process more than once and leave the children processes alone. This way I do not have children of children. The way I have it set up now it the parent process forks 3... (7 Replies)
Discussion started by: TWhitt24
7 Replies
10. Programming
I have an input file with contents like:
5785690|68690|898809
7960789|89709|789789
7669900|87865|659708
7869098|65769|347658
so on..
I need to pass this file to 10 parallely running processes (forking)so that each line is processed by a process and no line is processed twice and write the... (1 Reply)
Discussion started by: rkrish
1 Replies
FORK(2) BSD System Calls Manual FORK(2)
NAME
fork -- create a new process
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <unistd.h>
pid_t
fork(void);
DESCRIPTION
The fork() system call 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(2) or write(2) 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 process' resource utilizations are set to 0; see setrlimit(2).
o All interval timers are cleared; see setitimer(2).
o The child process has only one thread, corresponding to the calling thread in the parent process. If the process has more than one
thread, locks and other resources held by the other threads are not released and therefore only async-signal-safe functions (see
sigaction(2)) are guaranteed to work in the child process until a call to execve(2) or a similar function.
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
The fork() system call 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. The limit is given by the
sysctl(3) MIB variable KERN_MAXPROC. (The limit is actually ten less than this except for the super user).
[EAGAIN] The user is not the super user, and the system-imposed limit on the total number of processes under execution by a single
user would be exceeded. The limit is given by the sysctl(3) MIB variable KERN_MAXPROCPERUID.
[EAGAIN] The user is not the super user, and the soft resource limit corresponding to the resource argument RLIMIT_NPROC would be
exceeded (see getrlimit(2)).
[ENOMEM] There is insufficient swap space for the new process.
SEE ALSO
execve(2), rfork(2), setitimer(2), setrlimit(2), sigaction(2), vfork(2), wait(2)
HISTORY
The fork() function appeared in Version 6 AT&T UNIX.
BSD
May 31, 2013 BSD