LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-05-2012, 06:40 PM   #1
Embedded_guy
LQ Newbie
 
Registered: Nov 2012
Posts: 2

Rep: Reputation: Disabled
Smile Forked Child Process Inherits Library Linkage from Parent Process (All Unix Flavors)


Hi I am new to this forum and would like to verify that I am correct on a question.

When a child process is forked it inherits the parent's linkage to shared libraries and the linker-loader is not called?

For example:
The parent process has already has linkage to library_1 and make call with any one of its function. When a child process is created via a forked call it inherits the the linkage to library_1. I do not believe that any thing else is being done since a child process has a copy of the parents memory.

Thanks
 
Old 11-06-2012, 03:17 PM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
To me that is a correct assumption. The child is a complete copy of the parent, including all open descriptors.

If you're able to perform a fork(), then you should be able to test this in a similar manner:

Code:
pid_t pid;

pid = fork();

if(pid < 0) {
    // error condition, check errno
}
else if(pid == 0) {
    // This is the child, so invoke a call to the library to see if it works
}
else {
    // This is the parent, unless you wish to wait for the child to complete, nothing to be done here
    // you can of course validate here, or above the call to fork() to verify that the parent can call library
    // functions.  A helpful call would be waitpid(2), declare int w_status as a variable.
    waitpid(pid, &w_status, 0);
    // This would wait for the child to terminate and then you can invoke test macros against w_status.
    // see "man -S 2 waitpid for information on the various macros you can use to test the outcome of your child.
}
 
Old 11-09-2012, 09:42 PM   #3
Embedded_guy
LQ Newbie
 
Registered: Nov 2012
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thanks ........
 
Old 11-14-2012, 08:12 AM   #4
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 982
Blog Entries: 2

Rep: Reputation: 244Reputation: 244Reputation: 244
So no new ASLR if that's what you're asking.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
killng parent process without killing child process (Linux C programming) lettuce84@naver.com Linux - Newbie 3 07-24-2015 08:37 AM
Sending Signal from Child Process to Parent Process : Not getting desired output thelink123 Linux - General 4 10-26-2012 09:05 PM
child process usses same amount of ram as parent process socialjazz Programming 7 10-19-2006 05:48 PM
Bash Scripting - child process affecting parent process mthaddon Linux - General 1 05-02-2004 01:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration