Sponsored Content
Top Forums Shell Programming and Scripting does the pid of background process show in /proc? Post 302491980 by homeboy on Friday 28th of January 2011 10:05:34 PM
Old 01-28-2011
Quote:
Originally Posted by Corona688
What's this $_? The PID is $!
thanks for your reply,i'm sorry i made a careless mistake here,in my script i used $!Smilie,here is my code:
Code:
  1 #! /bin/bash
  2 
  3 #set -n
  4 
  5 TIMEOUT=$1
  6 count=0
  7 
  8 sleep $TIMEOUT & {
  9    while ((count < TIMEOUT));do
 10       eval '[ ! -d "/proc/$!" ] && ((count = TIMEOUT))'
 11       ((count++))
 12       sleep 1
 13       echo $!
 14    done
 15 
 16    eval '[ -d "/proc/$!" ] && kill -15 $! '
 17 }
~

---------- Post updated at 10:05 PM ---------- Previous update was at 10:02 PM ----------

Thanks to all above,it shows up in /proc,maybe i'm too careless to find it.....
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

PID of process started in background??

I am having a problem getting the PID of a process I start in the background is a csh. In tcsh and sh it's simple $! give it to you But in csh this just returns Variable syntax From the man page it should work but it doesn't???? Any help. (2 Replies)
Discussion started by: stilllooking
2 Replies

2. Red Hat

read maps from /proc/pid/

hi, i hav a query abt reading the contents of /proc/pid/maps file.is there any system apis or functions available to get the data from dat file and parse according to my need. i need name of the .so,Create date of the .so file.,Location of .so file etc. please provide a good source. yes i hav... (3 Replies)
Discussion started by: sanjaykhuntia
3 Replies

3. UNIX for Dummies Questions & Answers

Need to get pid of a process and have to store the pid in a variable

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

4. Shell Programming and Scripting

A question about the PID of a background function

Dear all, I'm writing a KornShell script that calls inside it a function in background mode #!/bin/ksh function myfunction { . . .} myfunction |& . . . How can I capture the PID of the function myfunction that runs in background? Thanks in advance :) (2 Replies)
Discussion started by: dariyoosh
2 Replies

5. Shell Programming and Scripting

kill PID running in background in for loop

Guys, can you help me in killing the process which is running in back ground under for loop I am not able to find the PID using ps -afx|grep <word in command I entered> (1 Reply)
Discussion started by: mohan_xunil
1 Replies

6. Shell Programming and Scripting

PID from background ssh

Hello. I was wondering if someone can help me out with something. To simplify my life, I have written a tiny script to open an ssh tunnel through another linux host so that I can access the esxi hosts on that network using the client. For this I have to tunnel ports 443, 902, and 903. Here is what... (1 Reply)
Discussion started by: numetheus
1 Replies

7. Shell Programming and Scripting

Background process, return code and pid.

Hey all, Okay, this one is tricky and I'm not sure there is a niec way to do it, or indeed anyway to do it. The main issue revolves around timing out a hung ssh. I am doing this by creating a wrapper script for the ssh with the following requirements. My requirements are: Defineable... (5 Replies)
Discussion started by: RECrerar
5 Replies

8. Shell Programming and Scripting

Closing open file descriptors from /proc/pid/fd

Hi guys, i need to write a shell script that will close file descriptors from /proc/pid/fd will calling exec 4<&- solve the problem ? thanks in advance :) (15 Replies)
Discussion started by: alpha_romeo
15 Replies

9. UNIX for Dummies Questions & Answers

/proc/pid/maps

I think the libc.so is shared between processes, because it is a shared library and OS is engaged for saving memory. But, below, the maps of bash, shows r-xp and r--p rw-p attributes to libc.so which mean private memory space. Can anybody explain this for me? :)cat /proc/$$/maps... (4 Replies)
Discussion started by: vistastar
4 Replies

10. Shell Programming and Scripting

[SOLVED] Using "$!" to get the PID of the Last Ran Background Process

Hello All, I was looking into creating a script that would be used only to start a Daemon and create a lock file... F.Y.I. It's for Nagios' NRPE Daemon Plugin... Anyway when I run the command to start the Daemon (below): /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d And... (14 Replies)
Discussion started by: mrm5102
14 Replies
TIMEOUT(1)							   User Commands							TIMEOUT(1)

NAME
timeout - run a command with a time limit SYNOPSIS
timeout [OPTION] NUMBER[SUFFIX] COMMAND [ARG]... timeout [OPTION] DESCRIPTION
Start COMMAND, and kill it if still running after NUMBER seconds. SUFFIX may be `s' for seconds (the default), `m' for minutes, `h' for hours or `d' for days. Mandatory arguments to long options are mandatory for short options too. -s, --signal=SIGNAL specify the signal to be sent on timeout. SIGNAL may be a name like `HUP' or a number. See `kill -l` for a list of signals --help display this help and exit --version output version information and exit If the command times out, then we exit with status 124, otherwise the normal exit status of the command is returned. If no signal is spec- ified, the TERM signal is sent. The TERM signal will kill processes which do not catch this signal. For other processes, it may be neces- sary to use the KILL (9) signal, since this signal cannot be caught. AUTHOR
Written by Padraig Brady. REPORTING BUGS
Report timeout bugs to bug-coreutils@gnu.org GNU coreutils home page: <http://www.gnu.org/software/coreutils/> General help using GNU software: <http://www.gnu.org/gethelp/> COPYRIGHT
Copyright (C) 2009 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. SEE ALSO
kill(1) The full documentation for timeout is maintained as a Texinfo manual. If the info and timeout programs are properly installed at your site, the command info coreutils 'timeout invocation' should give you access to the complete manual. GNU coreutils 7.1 July 2010 TIMEOUT(1)
All times are GMT -4. The time now is 02:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy