Sponsored Content
Full Discussion: Stateless process
Top Forums Shell Programming and Scripting Stateless process Post 302853373 by jim mcnamara on Friday 13th of September 2013 09:34:35 PM
Old 09-13-2013
I am confused by what you say you see. Processes either exist in the kernel process masthead or they do not exist. A non-running (terminated) process that has not been waited for is a zombie - the other possible states are states like sleep, swapped out, some kind of wait state, running, etc. There is no "stateless" value presented by ps.

I also do not get what your code is supposed to be doing.

If you want to check process existence try something like this:
Code:
# the 0 is a zero and does not harm the process, you have to be root or same user
# to signal any process
   kill 0 $pid && echo "$pid is alive" || echo "$pid is not alive"


Last edited by jim mcnamara; 09-13-2013 at 10:40 PM..
This User Gave Thanks to jim mcnamara For This Post:
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

script to monitor process running on server and posting a mail if any process is dead

Hello all, I would be happy if any one could help me with a shell script that would determine all the processes running on a Unix server and post a mail if any of the process is not running or aborted. Thanks in advance Regards, pradeep kulkarni. :mad: (13 Replies)
Discussion started by: pradeepmacha
13 Replies

2. Shell Programming and Scripting

Shell Script to Kill Process(number of process) Unix/Solaris

Hi Experts, we do have a shell script for Unix Solaris, which will kill all the process manullay, it used to work in my previous env, but now it is throwing this error.. could some one please help me to resolve it This is how we execute the script (and this is the requirement) ... (2 Replies)
Discussion started by: jonnyvic
2 Replies

3. Shell Programming and Scripting

script to monitor the process system when a process from user takes longer than 15 min run.

get email notification from from system when a process from XXXX user takes longer than 15 min run.Let me know the time estimation for the same. hi ,any one please tell me , how to write a script to get email notification from system when a process from as mentioned above a xxxx user takes... (1 Reply)
Discussion started by: kirankrishna3
1 Replies

4. Homework & Coursework Questions

Protect service with statefull, stateless

how to protect service dns with filtering tables (statefull, stateless)? iptables -L iptables ...? (1 Reply)
Discussion started by: nini
1 Replies

5. BSD

Process remians in Running state causing other similar process to sleep and results to system hang

Hi Experts, I am facing one problem here which is one process always stuck in running state which causes the other similar process to sleep state . This causes my system in hanged state. On doing cat /proc/<pid>wchan showing the "__init_begin" in the output. Can you please help me here... (0 Replies)
Discussion started by: naveeng
0 Replies

6. UNIX for Advanced & Expert Users

Process remians in Running state causing other similar process to sleep and results to system hang

Hi Experts, I am facing one problem here which is one process always stuck in running state which causes the other similar process to sleep state . This causes my system in hanged state. On doing cat /proc/<pid>wchan showing the "__init_begin" in the output. Can you please help me here... (1 Reply)
Discussion started by: naveeng
1 Replies

7. UNIX for Advanced & Expert Users

Process remians in Running state causing other similar process to sleep and results to system hang

Hi Experts, I am facing one problem here which is one process always stuck in running state which causes the other similar process to sleep state . This causes my system in hanged state. On doing cat /proc/<pid>wchan showing the "__init_begin" in the output. Can you please help me here... (6 Replies)
Discussion started by: naveeng
6 Replies

8. Shell Programming and Scripting

Monitoring processes in parallel and process log file after process exits

I am writing a script to kick off a process to gather logs on multiple nodes in parallel using "&". These processes create individual log files. Which I would like to filter and convert in CSV format after they are complete. I am facing following issues: 1. Monitor all Processes parallelly.... (5 Replies)
Discussion started by: shunya
5 Replies

9. Shell Programming and Scripting

Command to get exact tomcat process I am running ignoring other java process

Team, I have multiple batchjobs running in VM, if I do ps -ef |grep java or tomcat I am getting multiple process list. How do I get my exact tomcat process running and that is unique? via shell script? (4 Replies)
Discussion started by: Ghanshyam Ratho
4 Replies
waitpid(3C)						   Standard C Library Functions 					       waitpid(3C)

NAME
waitpid - wait for child process to change state SYNOPSIS
#include <sys/types.h> #include <sys/wait.h> pid_t waitpid(pid_t pid, int *stat_loc, int options); DESCRIPTION
The waitpid() function will suspend execution of the calling thread until status information for one of its terminated child processes is available, or until delivery of a signal whose action is either to execute a signal-catching function or to terminate the process. If more than one thread is suspended in waitpid(), wait(3C), or waitid(2) awaiting termination of the same process, exactly one thread will return the process status at the time of the target process termination. If status information is available prior to the call to waitpid(), return will be immediate. The pid argument specifies a set of child processes for which status is requested, as follows: o If pid is equal to (pid_t)-1, status is requested for any child process. If pid is greater than (pid_t)0, it specifies the process ID of the child process for which status is requested. o If pid is equal to (pid_t)0 status is requested for any child process whose process group ID is equal to that of the calling process. o If pid is less than (pid_t)-1, status is requested for any child process whose process group ID is equal to the absolute value of pid. One instance of a SIGCHLD signal is queued for each child process whose status has changed. If waitpid() returns because the status of a child process is available, and WNOWAIT was not specified in options, any pending SIGCHLD signal associated with the process ID of that child process is discarded. Any other pending SIGCHLD signals remain pending. If the calling process has SA_NOCLDWAIT set or has SIGCHLD set to SIG_IGN and the process has no unwaited children that were transformed into zombie processes, it will block until all of its children terminate, and waitpid() will fail and set errno to ECHILD. If waitpid() returns because the status of a child process is available, then that status may be evaluated with the macros defined by wait.h(3HEAD) If the calling process had specified a non-zero value of stat_loc, the status of the child process will be stored in the location pointed to by stat_loc. The options argument is constructed from the bitwise-inclusive OR of zero or more of the following flags, defined in the header <sys/wait.h>: WCONTINUED The status of any continued child process specified by pid, whose status has not been reported since it continued, is also reported to the calling process. WNOHANG The waitpid() function will not suspend execution of the calling process if status is not immediately available for one of the child processes specified by pid. WNOWAIT Keep the process whose status is returned in stat_loc in a waitable state. The process may be waited for again with identi- cal results. WUNTRACED The status of any child processes specified by pid that are stopped, and whose status has not yet been reported since they stopped, is also reported to the calling process. WSTOPPED is a synonym for WUNTRACED. RETURN VALUES
If waitpid() returns because the status of a child process is available, it returns a value equal to the process ID of the child process for which status is reported. If waitpid() returns due to the delivery of a signal to the calling process, -1 is returned and errno is set to EINTR. If waitpid() was invoked with WNOHANG set in options, it has at least one child process specified by pid for which status is not available, and status is not available for any process specified by pid, then 0 is returned. Otherwise, -1 is returned and errno is set to indicate the error. ERRORS
The waitpid() function will fail if: ECHILD The process or process group specified by pid does not exist or is not a child of the calling process or can never be in the states specified by options. EINTR The waitpid() function was interrupted due to the receipt of a signal sent by the calling process. EINVAL An invalid value was specified for options. USAGE
With options equal to 0 and pid equal to (pid_t)-1, waitpid() is identical to wait(3C). The waitpid() function is implemented as a call to the more general waitid(2) function. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |Async-Signal-Safe | +-----------------------------+-----------------------------+ SEE ALSO
intro(2), exec(2), exit(2), fork(2), pause(2), sigaction(2), ptrace(3C), signal(3C), siginfo.h(3HEAD), wait(3C), waitpid(3C), wait.h(3HEAD), attributes(5), standards(5) SunOS 5.10 19 Jun 2003 waitpid(3C)
All times are GMT -4. The time now is 03:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy