Sponsored Content
Top Forums Programming Beginners question about fork Post 302375149 by Corona688 on Thursday 26th of November 2009 04:12:36 PM
Old 11-26-2009
Quote:
Originally Posted by edgarvm
however the entire process of daemon will be forked
Forking is actually a fairly efficient way to create a process. Nearly all the memory of the old process can be shared or at least copy-on-write.
 

10 More Discussions You Might Find Interesting

1. Programming

simple fork question

When executing this simple program: #include <unistd.h> void main() { int f; printf("\n Parent procces ID=%d\n",getpid()); f=fork(); if(f==0) { printf("\n Child process ID=%d father=%d\n",getpid(),getppid()); } ... (2 Replies)
Discussion started by: bb666
2 Replies

2. Shell Programming and Scripting

awk - Beginners Question

I have my inputfile in the following format : From:sdhfhg dsfhsdjfjdsfh dsfjdjshjsd djfhsdjfjsdhjds Error Description <aa.aa.aa.aa.aa.aa> From:ksljfsdhfjh djfdsjkf sdjwoquk dsfsdfj Error Description <dd.dd.dd.dd.dd> I want to read the lines from tag 'From:' thrul <aa.aa.aa.aa.aa.aa>... (1 Reply)
Discussion started by: Amruta Pitkar
1 Replies

3. Programming

A small question about fork()

Hello experts, I am using fork() in my code but I am confused which output comes first child or parent? I did the following code .My book shows parent first but my linux shows child first.Can anyone tell me why? #include <stdio.h> int main(){ int pid; printf("I am original process with pid... (5 Replies)
Discussion started by: mlhazan
5 Replies

4. Programming

Question About Multi-Processed Applications... fork()

Assume we have an application built on *nix that uses fork()...then the processes procedure is going to act as follow: X is considered a parent process (first click on application) Y is considered a child process of X (second click on application) Z is considered a child process of Y (third... (6 Replies)
Discussion started by: f.ben.isaac
6 Replies

5. Shell Programming and Scripting

awk beginners question

hi, i start using awk and have a very basic problem. here's my code: #! /usr/bin/awk -f # 2010, scz # { $1 == "test" { print $2 } } this works on the command line but not as "program" - what is the difference between awk programs on the command line and executing awk... (3 Replies)
Discussion started by: svencz
3 Replies

6. Programming

multiple fork() question

I writing a program that forks three times but only on the parent process. The three children processes then produces output in order. 1, 2, 3. I am confused on how to do this. I have tried multiple if and else if statements but the output does not come out right. How should I go about doing this? (1 Reply)
Discussion started by: TWhitt24
1 Replies

7. Programming

Newbie question on exec,fork, wait,pipe C

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

question about fork

i'm experimenting fork function and i found this code #include <stdio.h> #include <sys/stat.h> #include <sys/types.h> #include <wait.h> #include <fcntl.h> #include <unistd.h> int main(void) { int fd; pid_t p; p = fork(); fork(); if (p>0) { fork();} fork(); fork();... (6 Replies)
Discussion started by: blob84
6 Replies

9. Programming

Linux fork, execv, wait question

Hi All, I have a program for class that needs to do the following: 1. Print the directory entries from the current directory using ncurses 2. Provide a prompt next to each directory entry and allow the user to enter commands that may or may not be about the file 3. Execute those commands in... (1 Reply)
Discussion started by: afulldevnull
1 Replies

10. UNIX for Beginners Questions & Answers

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()... (2 Replies)
Discussion started by: bodisha
2 Replies
pthread_rwlockattr_getpshared(3T)										 pthread_rwlockattr_getpshared(3T)

NAME
pthread_rwlockattr_getpshared(), pthread_rwlockattr_setpshared() - get or set the process-shared attribute SYNOPSIS
PARAMETERS
attr Pointer to the read-write lock attributes object whose attributes are to be set/retrieved. pshared This parameter either specifies the new value of the process-shared attribute (set function) or points to the memory loca- tion where the process-shared attribute of attr is to be returned (get function). DESCRIPTION
The attributes object attr must have been previously initialized with the function before these functions are called. Read-Write locks can be used only by threads within the process or shared by threads in multiple processes. The process-shared attribute in a read-write lock attributes object describes who may use the read-write lock. The legal values for the process-shared attribute are: This option permits a read-write lock to be operated upon by any thread that has access to the memory where the read-write lock is allocated. The application is responsible for allocating the read-write lock in memory that multiple processes can access. The read-write lock can only be operated upon by threads created within the same process as the thread that initialized the read-write lock. If threads of differing processes attempt to operate on such read-write lock, the behavior is undefined. The default value of process-shared is is used to set the process-shared attribute in the initialized attributes object attr. The new value of the process-shared attribute of attr is set to the value specified in the pshared parameter. retrieves the value of the process-shared attribute from the read-write lock attributes object attr. The value of the process-shared attribute of attr is returned in the pshared parameter. RETURN VALUE
Upon successful completion, and return zero. Otherwise, an error number is returned to indicate the error (the variable is not set). ERRORS
If any of the following occur, the and functions return the corresponding error number: is not defined and these functions are not supported. For each of the following conditions, if the condition is detected, the and functions return the corresponding error number: The value specified by attr is invalid. The value specified by pshared is not a legal value. The value pshared points to an illegal address. WARNINGS
If a read-write lock is created with the process-shared attribute defined as the cooperating processes should have access to the memory in which the read-write lock is allocated. AUTHOR
and were developed by X/Open. SEE ALSO
pthread_create(3T), pthread_rwlockattr_init(3T), pthread_rwlock_init(3T). STANDARDS CONFORMANCE
Pthread Library pthread_rwlockattr_getpshared(3T)
All times are GMT -4. The time now is 07:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy