- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: User unable to kill self process
Operating System - Linux
1753922
Members
7911
Online
108810
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-30-2007 12:22 AM
тАО11-30-2007 12:22 AM
User unable to kill self process
I know the /proc store the user login process , but I found that some user can't kill their SELF process in /proc , the file permission is dr-xr-xr-x , I am strange that some user can but some user can't , can advise what is wrong in my system ? can advise how can I make sure they can kill all their SELF process ? thx.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-30-2007 01:27 AM
тАО11-30-2007 01:27 AM
Re: User unable to kill self process
Hi:
You need to define the signal sent. Some signals can be trapped (caught) and ignored. For example, if you want a shell script to be immune to the user typing CTRL_C (which is a 'kill -INT') you would write:
#!/usr/bin/sh
trap 'echo I refuse to do that!' INT
while true
do
echo "Enter anything..."
read LINE
echo "You entered '${LINE}'"
done
Now, if you run this script you cannot stop it by either typing CTRL_C on the keyboard or by sending:
# kill -INT
A simple 'kill' command is the same as saying:
# kill -TERM
This is another signal that can be trapped and ignored.
Some signals cannot be caught or ignored. A 'kill -9' (kill -KILL) is one of them. Using this brutal kill should be a choice of last restort, however. If used, the program receiving this signal cannot 'trap' it and perform any cleanup of temporary files or shared memory before it exits. This can be deleterous to your server in the long run.
Regards!
...JRF...
You need to define the signal sent. Some signals can be trapped (caught) and ignored. For example, if you want a shell script to be immune to the user typing CTRL_C (which is a 'kill -INT') you would write:
#!/usr/bin/sh
trap 'echo I refuse to do that!' INT
while true
do
echo "Enter anything..."
read LINE
echo "You entered '${LINE}'"
done
Now, if you run this script you cannot stop it by either typing CTRL_C on the keyboard or by sending:
# kill -INT
A simple 'kill
# kill -TERM
This is another signal that can be trapped and ignored.
Some signals cannot be caught or ignored. A 'kill -9' (kill -KILL
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-03-2007 01:13 AM
тАО12-03-2007 01:13 AM
Re: User unable to kill self process
Your user might have misunderstood what /proc/self is.
Each process sees /proc/self as pointing to itself. If process 12345 examines /proc/self, it sees it pointing to /proc/12345; if process 4321 simultaneously examines /proc/self, for that process it points to /proc/4321. In /proc this is possible, because /proc is a virtual filesystem: all data in it is generated _at the time it's requested_.
When your user is viewing the directory listing of /proc, he/she usually sees the /proc/self as pointing to the process that lists the contents of the directory. If this process was started from the command line (i.e. the "ls" command), that process ends after producing the listing, so the information gained by examining /proc/self is already obsolete!
If your user tries to do something like:
kill $(cat /proc/self/stat | cut -d " " -f 1)
the expected result is something like:
bash: kill: (24482) - No such process
because the process number (here 24482) refers to the process that executed the "cat /proc/self/stat" command, which has already died when the kill command starts executing.
If your user is writing a script and wants the script to stop itself, the simplest way would be to use the command "exit". If the script needs to send some signal to itself for some reason, the variable $$ contains the process ID of the shell that's running the script. It's available in all POSIX-compliant shells, including bash.
The file permissions of /proc/self will not determine whether the user can kill a process or not. If a process is running with the same userid as the user, the user owns the process and can kill it.
MK
Each process sees /proc/self as pointing to itself. If process 12345 examines /proc/self, it sees it pointing to /proc/12345; if process 4321 simultaneously examines /proc/self, for that process it points to /proc/4321. In /proc this is possible, because /proc is a virtual filesystem: all data in it is generated _at the time it's requested_.
When your user is viewing the directory listing of /proc, he/she usually sees the /proc/self as pointing to the process that lists the contents of the directory. If this process was started from the command line (i.e. the "ls" command), that process ends after producing the listing, so the information gained by examining /proc/self is already obsolete!
If your user tries to do something like:
kill $(cat /proc/self/stat | cut -d " " -f 1)
the expected result is something like:
bash: kill: (24482) - No such process
because the process number (here 24482) refers to the process that executed the "cat /proc/self/stat" command, which has already died when the kill command starts executing.
If your user is writing a script and wants the script to stop itself, the simplest way would be to use the command "exit". If the script needs to send some signal to itself for some reason, the variable $$ contains the process ID of the shell that's running the script. It's available in all POSIX-compliant shells, including bash.
The file permissions of /proc/self will not determine whether the user can kill a process or not. If a process is running with the same userid as the user, the user owns the process and can kill it.
MK
MK
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP