- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- "kill -0" to a process owned by a different user.
Categories
Company
Local Language
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
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
Community
Resources
Forums
Blogs
- 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
тАО03-19-2010 03:59 AM
тАО03-19-2010 03:59 AM
"kill -0" to a process owned by a different user.
I have a process [pid] owned by user AAA and I want to access the pid [kill -0 pid ] from another user BBB.
I get a permission denied error when i tried it. Is there a way to get this "process access check" get working by any method??.
I have a custom code which does this stuff and need to get a exit code zero for the program to go further.
- Tags:
- kill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-19-2010 04:07 AM
тАО03-19-2010 04:07 AM
Re: "kill -0" to a process owned by a different user.
Instead of testing the pid with 'kill -0' I would suggest a simple interrogation with 'ps':
For example, by process name:
# PIDS=$(UNIX95= ps -C myprocess -opid=)
# [ -z "${PIDS}" ] && echo "dead" || echo "alive"
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-19-2010 05:28 AM
тАО03-19-2010 05:28 AM
Re: "kill -0" to a process owned by a different user.
#-------------------
PID=other_user_pid_no
test=`ps -e | awk '{print $1}' |grep $PID`
if [ "$test" != "$PID" ] ; then echo "We can not test the validity of $PID.";
exit 1;
else
# whatever...
exit 0;
fi
#-------------------
Best regards,
Horia.
Horia.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-19-2010 05:42 AM
тАО03-19-2010 05:42 AM
Re: "kill -0" to a process owned by a different user.
Too, if you know the pid and don't want to fiddle with the process name, you could do:
# PID=$(UNIX95= ps -p 1234 -opid=)
# [ -z "${PID}" ] && echo "dead" || echo "alive"
Obviously, substitute the actual pid in question for the "1234" value.
Once again, we leverage the UNIX95 behavior of 'ps' to create a custom output of *only* the pid *if* the pid can in fact be found. The '-opid=' says that the output should be the pid and that the normal 'ps' header line should be suppressed.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-19-2010 06:44 AM
тАО03-19-2010 06:44 AM
Re: "kill -0" to a process owned by a different user.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-19-2010 06:52 AM
тАО03-19-2010 06:52 AM
Re: "kill -0" to a process owned by a different user.
> I am not lloking for a code modify, rather any other possible changes we could get the same thing working.some unix tricks such as setuid, sticky bit , acl
Then create a 'setuid' executable that runs with an effective uid of zero.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-19-2010 06:58 AM
тАО03-19-2010 06:58 AM
Re: "kill -0" to a process owned by a different user.
If you have the PID and just want to know if the process exists or not, you should use the ps command with the -p option. If you want only the information about the existence of the process, throw the ps output away and use only the result code returned by the ps command.
Example:
#!/bin/sh
pid=1 # or whatever
if ps -p $pid >/dev/null; then
echo "process $pid exists"
else
echo "process $pid does not exist"
fi
MK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-21-2010 11:15 PM
тАО03-21-2010 11:15 PM
Re: "kill -0" to a process owned by a different user.
... or with the uid corresponding to user BBB.
Horia.
Horia.