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
IO::Select(3pm) 					 Perl Programmers Reference Guide					   IO::Select(3pm)

NAME
IO::Select - OO interface to the select system call SYNOPSIS
use IO::Select; $s = IO::Select->new(); $s->add(*STDIN); $s->add($some_handle); @ready = $s->can_read($timeout); @ready = IO::Select->new(@handles)->can_read(0); DESCRIPTION
The "IO::Select" package implements an object approach to the system "select" function call. It allows the user to see what IO handles, see IO::Handle, are ready for reading, writing or have an exception pending. CONSTRUCTOR
new ( [ HANDLES ] ) The constructor creates a new object and optionally initialises it with a set of handles. METHODS
add ( HANDLES ) Add the list of handles to the "IO::Select" object. It is these values that will be returned when an event occurs. "IO::Select" keeps these values in a cache which is indexed by the "fileno" of the handle, so if more than one handle with the same "fileno" is specified then only the last one is cached. Each handle can be an "IO::Handle" object, an integer or an array reference where the first element is an "IO::Handle" or an integer. remove ( HANDLES ) Remove all the given handles from the object. This method also works by the "fileno" of the handles. So the exact handles that were added need not be passed, just handles that have an equivalent "fileno" exists ( HANDLE ) Returns a true value (actually the handle itself) if it is present. Returns undef otherwise. handles Return an array of all registered handles. can_read ( [ TIMEOUT ] ) Return an array of handles that are ready for reading. "TIMEOUT" is the maximum amount of time to wait before returning an empty list, in seconds, possibly fractional. If "TIMEOUT" is not given and any handles are registered then the call will block. can_write ( [ TIMEOUT ] ) Same as "can_read" except check for handles that can be written to. has_exception ( [ TIMEOUT ] ) Same as "can_read" except check for handles that have an exception condition, for example pending out-of-band data. count () Returns the number of handles that the object will check for when one of the "can_" methods is called or the object is passed to the "select" static method. bits() Return the bit string suitable as argument to the core select() call. select ( READ, WRITE, EXCEPTION [, TIMEOUT ] ) "select" is a static method, that is you call it with the package name like "new". "READ", "WRITE" and "EXCEPTION" are either "undef" or "IO::Select" objects. "TIMEOUT" is optional and has the same effect as for the core select call. The result will be an array of 3 elements, each a reference to an array which will hold the handles that are ready for reading, writing and have exceptions respectively. Upon error an empty list is returned. EXAMPLE
Here is a short example which shows how "IO::Select" could be used to write a server which communicates with several sockets while also listening for more connections on a listen socket use IO::Select; use IO::Socket; $lsn = IO::Socket::INET->new(Listen => 1, LocalPort => 8080); $sel = IO::Select->new( $lsn ); while(@ready = $sel->can_read) { foreach $fh (@ready) { if($fh == $lsn) { # Create a new socket $new = $lsn->accept; $sel->add($new); } else { # Process socket # Maybe we have finished with the socket $sel->remove($fh); $fh->close; } } } AUTHOR
Graham Barr. Currently maintained by the Perl Porters. Please report all bugs to <perlbug@perl.org>. COPYRIGHT
Copyright (c) 1997-8 Graham Barr <gbarr@pobox.com>. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.16.2 2012-10-11 IO::Select(3pm)
All times are GMT -4. The time now is 04:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy