06-02-2009
Does anyone know the way to get any process PID inside of that process?
Ok, example:
Exist a function FUNK that in processing create temporary file and call other functions that use that file.
From process-1 I start background processed B1, B2, B3
Each call the FUNC
I need to be able to separate the files that FUNC will create.
That why I need the PID of each process INSIDE of that process! NOT in the parent process where B1,B2,B3 has been started.
I need the FUNC be able to get the B1 PID when it is running in B1, B2 PID when the FUNC is called in B2 and B3 ... - the same.
(I do not see a reason to reply on 'very constructive' responses as 'if I ever read manual', or on pretention that I expect the same PID, or on advise to get it by parent process )
10 More Discussions You Might Find Interesting
1. Programming
All,
I have a requirement to get the process name of the newly execv'd process.
After getting the complete process name, I need to carry out further operations on that.
Problem so far is how do I retrieve the name of the process ?
There is an API in windows called GetCommandLine. I... (2 Replies)
Discussion started by: vino
2 Replies
2. Shell Programming and Scripting
Hi Friends :p
I have a little problem please help me out. I have a Unix based OS Sun Server having oracle 8i as database on it. The server has one client with windows OS. The client uses developer 2000 (GUI) to run query and run processes. I want to know how can I know the PID of a process run... (3 Replies)
Discussion started by: vanand420
3 Replies
3. Solaris
hi all,
Is there a simple script anyone could through out to me, to find the pid of a process given the name. I actually need to bind this pid to a processor set. I would probably put these comamns in a shell script which would have.
a) kick start the executable
b) get the pid
c) bind it to a... (10 Replies)
Discussion started by: Naanu
10 Replies
4. Linux
I am trying to submit a background process on a remote machine using
ssh -f remote-host "sh my-process.sh"
Normally the process will be submitted and control returned to the local machine (even when the process is running on the remote machine)
I want to get the process id of the submitted... (4 Replies)
Discussion started by: superuser84
4 Replies
5. UNIX for Dummies Questions & Answers
Hi,
I need to get the pid of a process and have to store the pid in a variable and i want to use this value(pid) of the variable for some process. Please can anyone tell me how to get the pid of a process and store it in a variable. please help me on this.
Thanks in advance,
Amudha (7 Replies)
Discussion started by: samudha
7 Replies
6. Shell Programming and Scripting
Hi
I have written a shell script to find and kill the particular process. Here in shell script i have written the code like
cnt = $(ps -ef | grep Shree)
echo $cnt
I am getting the output
root 2326 2317 0 14:39:46 pts/1 0:28 Shree -f fdc.fbconf FDCapp.fbapp
Here I want to... (2 Replies)
Discussion started by: Shreedhar Naik
2 Replies
7. Shell Programming and Scripting
Hi all,
i was able to redirect pid of process to a file in the following way
ps aux|awk '$11 == "/Applications/ProjectX/DServer" >> /Applications/ProjectX/DServer.pid
it works fine but if one folder name caontains space its not working like below
ps aux|awk '$11 == "/Applications/Project\... (1 Reply)
Discussion started by: kirankumars
1 Replies
8. Programming
Hi
I use linux OS.
I've already written a function that allow me to get the process name by pid. (searching in /proc). Now I'd like to perform the inverse task.I mean get the process pid by its name.
I could write a function that search in every folder in /proc for the process name, but i... (2 Replies)
Discussion started by: Dedalus
2 Replies
9. Shell Programming and Scripting
Hi All,
I need to get the PID of a process which i ran in background into a variable
echo $! gives me the PID of last background process but how to get this into a variable so that i can use "wait" command later in the script to make sure that this background process was done
var = `echo... (5 Replies)
Discussion started by: firestar
5 Replies
10. AIX
HI,
i used
ps -ef | grep 3539052 | grep -v grep
and i got a output like ths
root 3539052 3407918 0 May 07 - 709:31 /usr/sbin/syslogd
but what i need is instead of full path /usr/sbin/syslogd i want only the process name that is 'syslogd' here. (3 Replies)
Discussion started by: sumanthupar
3 Replies
LEARN ABOUT XFREE86
systemd-notify
SYSTEMD-NOTIFY(1) systemd-notify SYSTEMD-NOTIFY(1)
NAME
systemd-notify - Notify service manager about start-up completion and other daemon status changes
SYNOPSIS
systemd-notify [OPTIONS...] [VARIABLE=VALUE...]
DESCRIPTION
systemd-notify may be called by daemon scripts to notify the init system about status changes. It can be used to send arbitrary
information, encoded in an environment-block-like list of strings. Most importantly, it can be used for start-up completion notification.
This is mostly just a wrapper around sd_notify() and makes this functionality available to shell scripts. For details see sd_notify(3).
The command line may carry a list of environment variables to send as part of the status update.
Note that systemd will refuse reception of status updates from this command unless NotifyAccess= is set for the service unit this command
is called from.
Note that sd_notify() notifications may be attributed to units correctly only if either the sending process is still around at the time PID
1 processes the message, or if the sending process is explicitly runtime-tracked by the service manager. The latter is the case if the
service manager originally forked off the process, i.e. on all processes that match NotifyAccess=main or NotifyAccess=exec. Conversely, if
an auxiliary process of the unit sends an sd_notify() message and immediately exits, the service manager might not be able to properly
attribute the message to the unit, and thus will ignore it, even if NotifyAccess=all is set for it.
systemd-notify will first attempt to invoke sd_notify() pretending to have the PID of the invoking process. This will only succeed when
invoked with sufficient privileges. On failure, it will then fall back to invoking it under its own PID. This behaviour is useful in order
that when the tool is invoked from a shell script the shell process -- and not the systemd-notify process -- appears as sender of the
message, which in turn is helpful if the shell process is the main process of a service, due to the limitations of NotifyAccess=all
described above.
OPTIONS
The following options are understood:
--ready
Inform the init system about service start-up completion. This is equivalent to systemd-notify READY=1. For details about the semantics
of this option see sd_notify(3).
--pid=
Inform the init system about the main PID of the daemon. Takes a PID as argument. If the argument is omitted, the PID of the process
that invoked systemd-notify is used. This is equivalent to systemd-notify MAINPID=$PID. For details about the semantics of this option
see sd_notify(3).
--uid=USER
Set the user ID to send the notification from. Takes a UNIX user name or numeric UID. When specified the notification message will be
sent with the specified UID as sender, in place of the user the command was invoked as. This option requires sufficient privileges in
order to be able manipulate the user identity of the process.
--status=
Send a free-form status string for the daemon to the init systemd. This option takes the status string as argument. This is equivalent
to systemd-notify STATUS=.... For details about the semantics of this option see sd_notify(3).
--booted
Returns 0 if the system was booted up with systemd, non-zero otherwise. If this option is passed, no message is sent. This option is
hence unrelated to the other options. For details about the semantics of this option, see sd_booted(3). An alternate way to check for
this state is to call systemctl(1) with the is-system-running command. It will return "offline" if the system was not booted with
systemd.
-h, --help
Print a short help text and exit.
--version
Print a short version string and exit.
EXIT STATUS
On success, 0 is returned, a non-zero failure code otherwise.
EXAMPLE
Example 1. Start-up Notification and Status Updates
A simple shell daemon that sends start-up notifications after having set up its communication channel. During runtime it sends further
status updates to the init system:
#!/bin/bash
mkfifo /tmp/waldo
systemd-notify --ready --status="Waiting for data..."
while : ; do
read a < /tmp/waldo
systemd-notify --status="Processing $a"
# Do something with $a ...
systemd-notify --status="Waiting for data..."
done
SEE ALSO
systemd(1), systemctl(1), systemd.unit(5), sd_notify(3), sd_booted(3)
systemd 237 SYSTEMD-NOTIFY(1)