LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 02-02-2006, 08:31 AM   #1
arunj
LQ Newbie
 
Registered: Feb 2006
Posts: 10

Rep: Reputation: 0
get the PID of a separate process (no parent-child relationship)


Hi friends,

Can anybody plz tell me how I can get the PID of a concurrent process from a second process which does not have any parent-child relationship between them? Both processes have only one instance and one process knows the name of the other process.
Plz give me a solution other than using the system() function. Is there any system call that can help me?

Thanks,
Arun
 
Old 02-02-2006, 08:37 AM   #2
trickykid
Guru
 
Registered: Jan 2001
Posts: 24,133

Rep: Reputation: 199Reputation: 199
pstree might help..
 
Old 02-02-2006, 09:24 AM   #3
arunj
LQ Newbie
 
Registered: Feb 2006
Posts: 10

Original Poster
Rep: Reputation: 0
But pstree too is a shell command (as far as I know). I need some function that will help me retrieve the PID of the process concerned. I have only one one instance of each process running. So in this case, I may make each process name unique.
 
Old 02-02-2006, 11:36 AM   #4
rimkus
LQ Newbie
 
Registered: Jan 2006
Posts: 9

Rep: Reputation: 0
It is hokey but have the process write its pid to a file and read the file. What language are you using?
You might try putting the pid in shared memory.
 
Old 02-02-2006, 12:31 PM   #5
sundialsvcs
Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 5,401

Rep: Reputation: 1119Reputation: 1119Reputation: 1119Reputation: 1119Reputation: 1119Reputation: 1119Reputation: 1119Reputation: 1119Reputation: 1119
Usually, "pid-files" is what I see most processes do. They write their PID to a file on startup, and remove it when they shut down.

A shared-memory segment would also be a good idea.

It occurs to me that you could also walk through the /proc "directory" ...
 
Old 02-03-2006, 12:14 AM   #6
arunj
LQ Newbie
 
Registered: Feb 2006
Posts: 10

Original Poster
Rep: Reputation: 0
Thanks rimkus and sundialsvcs!

"pid-files" is really a good idea if the processes automatially (using kernel intervention) do that. If possible, please gimme some more information while I'm myself diving into it. I'm also going through /proc directory to find this out. I'm using the gcc library only. In fact, my work is related to Embedded Linux and I'm facing a lot of memory constraints because of the design of the hardware I'm working on.

Thanks once again,

Arun
 
Old 02-03-2006, 01:50 AM   #7
arunj
LQ Newbie
 
Registered: Feb 2006
Posts: 10

Original Poster
Rep: Reputation: 0
Let me explain. Right now I want to send a message from one process to another process (name known, right now, only a single instance) which will lead to the invocation of some function by the second process. The two processes are unrelated. If this isn't possible without handling the pid and other info by a third process (which is going to manage), I have to make arrangements for information passing between the processes using the third one. I don't want to use shared memory right now and the best alternative is passing pointers. How can I pass these pointers between the proceses without any copying of data (i.e., the pointers will be accessible to all the processes)?

Thanks,
Arun
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
When I kill parent process, child isn't killed BengeBoy Linux - Software 0 08-19-2004 04:38 PM
Bash Scripting - child process affecting parent process mthaddon Linux - General 1 05-02-2004 01:19 PM
parent and child processes skora Programming 5 11-02-2003 10:41 AM
about parent and child process winwar Solaris / OpenSolaris 3 07-23-2003 06:07 AM
child and parent process error jdevanand Programming 1 04-29-2002 08:13 AM


All times are GMT -5. The time now is 07:54 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration