Is there realy no other way to get to the PID?
In the shell its's automaticly diplayed.
Main Topics
Browse All Topics# Tools
C++, GNU, Linux
# Goal
Play an audio file in a c++ application using gstream via a system cmd like this:
$ gst-launch-0.10 playbin uri=file:///home/krebs/tes
The "kill" function should be used to stop.
# Problem
To kill the gsrteam process a id is reqired and i don't now how to get it. ok, there is a possibility seraching the "/proc/" folder by the process name, but i hope therer is easier solution.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Sounds like a job for killall - kill processes by name:
http://linux.die.net/man/1
>> kill processes by name
This really should be done with care because it can kill ALL processes of that name (assuming the user has the correct privilidges to kill each processes). It is for this reason I didn't suggest this. The forking of a new process and then calling exec to replace this process is going to be safer. Still, if killall serves your purpose then so be it.
>> Is there realy no other way to get to the PID?
>> In the shell its's automaticly diplayed.
That is because the shell basically forked off the process (that is now running in the background), so it has access the the process id, and can display it to the user for future use.
Note that every process has access to its own process id using getpid :
http://linux.die.net/man/2
so, for your process, you can get its process id, and pass it on to wherever you need it.
The process id is the principal identifier of a process, so if you need to get access to a certain process, you need a way to get its process id, either by getting fork's return value if it's a child process, or other means if it's not.
Business Accounts
Answer for Membership
by: evilrixPosted on 2009-04-18 at 06:19:13ID: 24175161
You could try this...
nlinepubs/ 000095399/ functions/ fork.html nlinepubs/ 000095399/ functions/ exec.html
Use fork() to have your process spawn a child, fork() will return the pid of the new child. The child process can then start your external command using one of the exec() functions, which will replace your child process in memory but preserve the pid. The idea is that you then signal the child process from the parent, using the pid obtained from fork().
http://www.opengroup.org/o
http://www.opengroup.org/o
BTW: This is just a suggestion, I have not tested it.