- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Show Open Files
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
10-18-2002 07:07 AM
10-18-2002 07:07 AM
Does anyone know how to show if a file is open from "C"? I know about the fuser command, but it executes from the command line. I need a library call from "C".
Tom
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2002 07:11 AM
10-18-2002 07:11 AM
Re: Show Open Files
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2002 07:12 AM
10-18-2002 07:12 AM
Re: Show Open Files
http://gatekeep.cs.utah.edu/hppd/hpux/Sysadmin/lsof-4.64/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2002 07:13 AM
10-18-2002 07:13 AM
Re: Show Open Files
Try downloading and installing the lsof utility. This link has links to various sites:
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0xee1a6049dbb6d611abdb0090277a778c,00.html
Hope this helps
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2002 07:14 AM
10-18-2002 07:14 AM
Re: Show Open Files
I don't know the PID. I need to check if log files are open before launching a process. If the log files are open, I need to build a command that uses a different simulation model and logfile.
Tom
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2002 07:22 AM
10-18-2002 07:22 AM
Re: Show Open Files
I'm going to try to get the pstat_getfile() function to work. Does anyone have a code snippet?
Tom
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2002 12:00 PM
10-21-2002 12:00 PM
SolutionOnce you have the file system id and inode number you loop through every process and open file to find matches.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2002 12:20 PM
10-21-2002 12:20 PM
Re: Show Open Files
FILE* fp = NULL;
char *strFileName = "myfile.txt";
fp = fopen(strFileName, "r");
if (fp) {
printf("file %s is open", strFileName);
}
here if (fp) will execute only if file is open..
Vishnu.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2002 03:33 AM
10-22-2002 03:33 AM
Re: Show Open Files
Very slick! It found the open files I was looking for!
But I did have a problem compiling. The first error message I got said I needed an ANSI compiler. So I tried my gcc. Then I got this goofy error message:
So I modified the main declaration to look like this:
int main(argc, argv, envp)
int argc;
char *argv[];
char *envp[];
And I was able to cc it.
Thanks for your help!
Tom