- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Problem with kill signal in C code
Operating System - HP-UX
1819804
Members
3170
Online
109607
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
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
Go to solution
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
тАО10-18-2010 07:20 AM
тАО10-18-2010 07:20 AM
I am running some C code with the following version of cc: HP C/aC++ B3910B A.06.25 [Nov 30 2009]. My platform is HP-UX 11.31 Itanium.
I have code similar to the code below, where ProcessId has the value of a process that is running on the system. I can run ps -ef|grep to verify that the process is in fact running. When I use the C 'kill' function to send a SIGNULL signal to the process to check the status, it always returns a status of -1. I am including at the top of the module. Why is this process showing up as having a status of -1 when ps -ef shows that the process is running?
int ProcessStatus = -1;
ProcessStatus = kill(ProcessId, 0);
Here are the processes shown by ps -ef|grep drm:
marcs 27052 1349 0 11:17:02 ? 0:00 /bin/sh /home/cacsg/mich2/exec/s
tart_drm marcs /home/cacsg/mich2
marcs 27079 1349 0 11:17:05 ? 0:00 /bin/sh /home/cacsg/mich2/exec/s
tart_drm marcs /home/cacsg/mich2
marcs 27047 1349 0 11:17:01 ? 0:00 /bin/sh /home/cacsg/mich2/exec/s
tart_drm marcs /home/cacsg/mich2
marcs 27062 27061 9 11:17:04 ?
marcs 27061 1349 0 11:17:04 ? 0:00 /bin/sh /home/cacsg/mich2/exec/s
tart_drm marcs /home/cacsg/mich2
marcs 27048 27047 0 11:17:01 ?
I have code similar to the code below, where ProcessId has the value of a process that is running on the system. I can run ps -ef|grep
int ProcessStatus = -1;
ProcessStatus = kill(ProcessId, 0);
Here are the processes shown by ps -ef|grep drm:
marcs 27052 1349 0 11:17:02 ? 0:00 /bin/sh /home/cacsg/mich2/exec/s
tart_drm marcs /home/cacsg/mich2
marcs 27079 1349 0 11:17:05 ? 0:00 /bin/sh /home/cacsg/mich2/exec/s
tart_drm marcs /home/cacsg/mich2
marcs 27047 1349 0 11:17:01 ? 0:00 /bin/sh /home/cacsg/mich2/exec/s
tart_drm marcs /home/cacsg/mich2
marcs 27062 27061 9 11:17:04 ?
marcs 27061 1349 0 11:17:04 ? 0:00 /bin/sh /home/cacsg/mich2/exec/s
tart_drm marcs /home/cacsg/mich2
marcs 27048 27047 0 11:17:01 ?
Solved! Go to Solution.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-18-2010 07:43 AM
тАО10-18-2010 07:43 AM
Solution
Please check the value of the variable "errno" after calling the "kill" function. It is the standard variable used by many system functions to further describe the causes of error conditions.
The possible errno values after calling kill() are listed in the kill(2) man page (i.e. see "man 2 kill", look for heading "ERRORS").
I guess you might be getting EPERM, if you're trying to kill a process running as a different user. But you could use that as a confirmation the process exists too: if the process wasn't there, you would be getting ESRCH instead.
> Here are the processes shown by ps -ef|grep drm:
As you didn't tell what was the ProcessId you used nor what username you're using for running your program, this information alone is useless for solving the problem.
MK
The possible errno values after calling kill() are listed in the kill(2) man page (i.e. see "man 2 kill", look for heading "ERRORS").
I guess you might be getting EPERM, if you're trying to kill a process running as a different user. But you could use that as a confirmation the process exists too: if the process wasn't there, you would be getting ESRCH instead.
> Here are the processes shown by ps -ef|grep drm:
As you didn't tell what was the ProcessId you used nor what username you're using for running your program, this information alone is useless for solving the problem.
MK
MK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-18-2010 08:10 AM
тАО10-18-2010 08:10 AM
Re: Problem with kill signal in C code
I ran the following command line command and here's what I got. I found the user of one process is mich2 and the user of the process it is trying to kill -0 is marcs.
d1marcs:/home/cacsg/mich2/source/drm>
kill -0 29844
kill: 29844: Permission denied.
d1marcs:/home/cacsg/mich2/source/drm>
d1marcs:/home/cacsg/mich2/source/drm>
kill -0 29844
kill: 29844: Permission denied.
d1marcs:/home/cacsg/mich2/source/drm>
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.
Company
Learn About
News and Events
Support
© Copyright 2025 Hewlett Packard Enterprise Development LP