- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Process existence.
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
Forums
Discussions
Discussions
Discussions
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
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
11-29-2000 10:54 PM
11-29-2000 10:54 PM
Process existence.
Hi Admin,
Is there an API support to know if a process is already running ?
I had tried
system("export aVar=ps -e | grep -v grep | grep -n Procname);
but it did not work.
Would someone advise me how I can get this status.
Sandip
- Tags:
- PS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2000 01:13 AM
11-30-2000 01:13 AM
Re: Process existence.
This works for a single process:
#include
main()
{
FILE *command;
long process_id;
char pnum[12];
command=popen("ps -ef|grep lpsched | grep -v grep|awk '{print $2}'","r");
fgets(pnum,12,command);
process_id=atol(pnum);
printf("process number = %ld\n",process_id);
}
Best regards,
Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2000 01:14 AM
11-30-2000 01:14 AM
Re: Process existence.
I didn't mention that it was a "quick and dirty" solution but you realised that by yourself, didn't you?
;-)
Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2000 01:17 AM
11-30-2000 01:17 AM
Re: Process existence.
In the pstat(2) manpage, there are lots of useful examples, such as this one:
/*
* Example 4: Get a particular process' information
*/
{
struct pst_status pst;
int target = (int)getppid();
if (pstat_getproc(&pst, sizeof(pst), (size_t)0, target) != -1)
(void)printf("Parent started at %s", ctime(&pst.pst_start));
else
perror("pstat_getproc");
}
Hope that helps !
Regards.
- Tags:
- pstat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2000 01:26 AM
11-30-2000 01:26 AM
Re: Process existence.
Your solution will only be useful for the current process (PID), or the parent (PPID)
I understood that Sandip is checking for a totally unrelated process.
Best regards,
Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2000 04:47 AM
11-30-2000 04:47 AM
Re: Process existence.
Your example is better than mine :o)
I simply wanted Sandip to look at pstat(2) manpage for further help.
Regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2000 04:52 AM
11-30-2000 04:52 AM
Re: Process existence.
Don't take offence, please! I was just trying to clarify the initial question.
My example wasn't any better than yours, I even mentioned above that it was a "quick and dirty" solution, didn't I ?
;-)
Cheers,
Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2000 05:06 AM
11-30-2000 05:06 AM
Re: Process existence.
I did not feel offended at all !
I really thought what I said, and I agreed that your example, even quick and dirty, was really what Sandip was looking for !
Again, sorry for misunderstanding !!
Best regards.