- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- One call to close()/fclose() closes all file descr...
Operating System - HP-UX
1753519
Members
4330
Online
108795
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
тАО01-16-2003 01:38 PM
тАО01-16-2003 01:38 PM
One call to close()/fclose() closes all file descriptors ?
Hi
A strange question, due to a strange thing ...
A program of that was invoked from a ksh script had destroyed a binary file.
Looking at the file, we found that the program had written an error message, which should have been written to STDERR.
This we believe had happend since somewhere, the STDERR file or its handle (2)were closed.
As a result, the handle - 2 was assigned to the binary file, which was later corrupted.
So far, I could not find any place where the STDERR was closed.
Using lsof, I'd found that the script file, which had invoked the problem had redirected STDOUT (1) and STDERR (2) to a file, which was later opened again by the problematic program.
To sum things up - this file was opened 3 times - 2 by the calling script (which had passed its open files to the program), and by the program itself.
When the program ends. it closes that file once, but there're cases where I believe/think (no sure..) all the file handles are closed - including STDERR.
Right now, I'm looking for an answer whether - one call to fclose() or close() functions close or release ANY/ALL file descriptor(s), that are assinged to the file that is closed.
Thanks for your assistance.
A strange question, due to a strange thing ...
A program of that was invoked from a ksh script had destroyed a binary file.
Looking at the file, we found that the program had written an error message, which should have been written to STDERR.
This we believe had happend since somewhere, the STDERR file or its handle (2)were closed.
As a result, the handle - 2 was assigned to the binary file, which was later corrupted.
So far, I could not find any place where the STDERR was closed.
Using lsof, I'd found that the script file, which had invoked the problem had redirected STDOUT (1) and STDERR (2) to a file, which was later opened again by the problematic program.
To sum things up - this file was opened 3 times - 2 by the calling script (which had passed its open files to the program), and by the program itself.
When the program ends. it closes that file once, but there're cases where I believe/think (no sure..) all the file handles are closed - including STDERR.
Right now, I'm looking for an answer whether - one call to fclose() or close() functions close or release ANY/ALL file descriptor(s), that are assinged to the file that is closed.
Thanks for your assistance.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-16-2003 02:42 PM
тАО01-16-2003 02:42 PM
Re: One call to close()/fclose() closes all file descriptors ?
The close() system call or its higher level equivalents, fclose() and pclose(), close only one file descriptor. Even in the case of the most closely coupled file descriptors created using the dup() system call, a close is required for both file descriptors. I've never seen any flavor of UNIX behave differently.
man 2 close and 2 dup for more details.
man 2 close and 2 dup for more details.
If it ain't broke, I can fix that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-17-2003 01:49 AM
тАО01-17-2003 01:49 AM
Re: One call to close()/fclose() closes all file descriptors ?
Hi
Thanks for your very quick reply.
I had to send my question after a long time that I could not find an answer.
The problem only exists on one installation out of more that 5000 of my company's software, and so far, I could find a reasonable explaination (the ony one I have now that it's simply a tricky bug ... I'll try to keep you all update if I find anything.
Thanks
Shay
Thanks for your very quick reply.
I had to send my question after a long time that I could not find an answer.
The problem only exists on one installation out of more that 5000 of my company's software, and so far, I could find a reasonable explaination (the ony one I have now that it's simply a tricky bug ... I'll try to keep you all update if I find anything.
Thanks
Shay
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