Sponsored Content
Top Forums Shell Programming and Scripting Terminate processes for CLOSE_WAIT status of TCP Post 302760769 by Corona688 on Thursday 24th of January 2013 02:54:36 PM
Old 01-24-2013
You can emulate -q with >/dev/null.

You also don't need $? at all.

Code:
if /usr/proc/bin/pfiles $pid 2>/dev/null | grep "port: $PORT" >/dev/null
then
       echo "Port: $PORT is being used by PID: \c" 
                   ps -o pid -o args -p $PID | sed 1d
fi

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

retrieving exit status from background processes

Hi, I need to retrieve the exit status of 4 moves running as background processes. The wait command will not work since it can only give me the exit status of the last of the background processes. Here's a sample of what I need !#/bin/ksh mv /dir1/subdir1/*.Z /dir6/subdir6/ & mv... (2 Replies)
Discussion started by: MG537
2 Replies

2. UNIX for Advanced & Expert Users

clear CLOSE_WAIT status

Hi, I have an application with a bug in it that keeps sockets in CLOSE_WAIT, which eventually freezes the server because the user account it runs under runs out of file handles. We have the bug fixed but can only release the fix with the next release. Does anyone know how I can clear the... (3 Replies)
Discussion started by: rein
3 Replies

3. UNIX for Dummies Questions & Answers

How to check the status of the processes running for the current user?

Hi All, I am new to unix. Can anyone tell me "How to check the status of the processes running for the current user?" Regards, Ravindaran S (1 Reply)
Discussion started by: ravind27
1 Replies

4. Programming

How to check TCP server status

Please tell me according to C/C++ socket programming; how client can check whether server is running or not during TCP communication. (1 Reply)
Discussion started by: mansoorulhaq
1 Replies

5. Programming

TCP status question

There is a server and a client,when client send a message to server,server can send a reply to client. The status of server and client is ESTABLISHED.Then I halt the client,I find the server status is CLOSE_WAIT and the client status is FIN_WAIT_2. Many minutes passed,I find the the server status... (1 Reply)
Discussion started by: konvalo
1 Replies

6. Red Hat

How to kill a TCP connection which has status TIME_WAIT & no PID

Hi, I want to kill TCP connections which have status as TIME_WAIT & no PID (as per the output of the "netstat - p" command). Is there any command/utility available to kill connections to a specific port or IP address. The problem is that these connections don't have process ID (see... (4 Replies)
Discussion started by: Davinder31may
4 Replies

7. Programming

Getting TCP Port status through C API

Does anyone know if there is a C API call to get the status of a TCP port? As opposed to running netstat and parsing the results. At the moment I have to attempt to bind() and pick up on the address in use error which isn't very elegant Thanks ---------- Post updated at 10:42 AM ----------... (0 Replies)
Discussion started by: janra
0 Replies

8. Shell Programming and Scripting

Executing multiple processes without waiting for their exit status.

Hello Friends, Hope you are doing well. I just need a help in executing multiple processes. I've written a shell script which calls another scritps. But the problem is there are too many processes to run, and each process takes about a min to finish its execution. So, I want to just... (3 Replies)
Discussion started by: singh.chandan18
3 Replies

9. UNIX for Dummies Questions & Answers

Processes and exit status

Hi, I can't understand why the last $? is 1? can somebody plz help me to understand it? thanks $ ksh $ ps -f UID PID PPID C STIME TTY TIME COMMAND msarabad 12361 12319 0 15:17:58 pts/1 0:00 ksh msarabad 12319 12317 0 15:15:11 pts/1 0:00 -sh msarabad 12362 12361 ... (7 Replies)
Discussion started by: messi777
7 Replies

10. AIX

How to repair a TCP/IP socket in state: CLOSE_WAIT?

Hi The clients connect to my server -using port 9130. But no client could connect to my server at this time. I've checked already and this is the result netstat -Aan|grep -v 127.0.0.1|grep 9130|pg f10006000abcb398 tcp4 10313 0 10.0.89.81.9130 10.158.70.24.1705 CLOSE_WAIT... (8 Replies)
Discussion started by: bobochacha29
8 Replies
NSENTER(1)							   User Commands							NSENTER(1)

NAME
nsenter - run program with namespaces of other processes SYNOPSIS
nsenter [options] [program] [arguments] DESCRIPTION
Enters the namespaces of one or more other processes and then executes the specified program. Enterable namespaces are: mount namespace mounting and unmounting filesystems will not affect rest of the system (CLONE_NEWNS flag), except for filesystems which are explic- itly marked as shared (by mount --make-shared). See /proc/self/mountinfo for the shared flag. UTS namespace setting hostname, domainname will not affect rest of the system (CLONE_NEWUTS flag). IPC namespace process will have independent namespace for System V message queues, semaphore sets and shared memory segments (CLONE_NEWIPC flag). network namespace process will have independent IPv4 and IPv6 stacks, IP routing tables, firewall rules, the /proc/net and /sys/class/net directory trees, sockets etc. (CLONE_NEWNET flag). PID namespace children will have a set of PID to process mappings separate from the nsenter process (CLONE_NEWPID flag). nsenter will fork by default if changing the PID namespace, so that the new program and its children share the same PID namespace and are visible to each other. If --no-fork is used, the new program will be exec'ed without forking. See the clone(2) for exact semantics of the flags. If program is not given, run ``${SHELL}'' (default: /bin/sh). OPTIONS
Argument with square brakets, such as [file], means optional argument. Command line syntax to specify optional argument --mount=/path/to /file. Please notice the equals sign. -t, --target pid Specify a target process to get contexts from. The paths to the contexts specified by pid are: /proc/pid/ns/mnt the mount namespace /proc/pid/ns/uts the UTS namespace /proc/pid/ns/ipc the IPC namespace /proc/pid/ns/net the network namespace /proc/pid/ns/pid the PID namespace /proc/pid/root the root directory /proc/pid/cwd the working directory respectively -m, --mount [file] Enter the mount namespace. If no file is specified enter the mount namespace of the target process. If file is specified enter the mount namespace specified by file. -u, --uts [file] Enter the UTS namespace. If no file is specified enter the UTS namespace of the target process. If file is specified enter the UTS namespace specified by file. -i, --ipc [file] Enter the IPC namespace. If no file is specified enter the IPC namespace of the target process. If file is specified enter the IPC namespace specified by file. -n, --net [file] Enter the network namespace. If no file is specified enter the network namespace of the target process. If file is specified enter the network namespace specified by file. -p, --pid [file] Enter the PID namespace. If no file is specified enter the PID namespace of the target process. If file is specified enter the PID namespace specified by file. -r, --root [directory] Set the root directory. If no directory is specified set the root directory to the root directory of the target process. If direc- tory is specified set the root directory to the specified directory. -w, --wd [directory] Set the working directory. If no directory is specified set the working directory to the working directory of the target process. If directory is specified set the working directory to the specified directory. -F, --no-fork Do not fork before exec'ing the specified program. By default when entering a pid namespace enter calls fork before calling exec so that the children will be in the newly entered pid namespace. -V, --version Display version information and exit. -h, --help Print a help message. SEE ALSO
setns(2), clone(2) AUTHOR
Eric Biederman <ebiederm@xmission.com> AVAILABILITY
The nsenter command is part of the util-linux package and is available from Linux Kernel Archive <ftp://ftp.kernel.org/pub/linux/utils /util-linux/>. util-linux January 2013 NSENTER(1)
All times are GMT -4. The time now is 06:15 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy