- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: class "std::basic_ofstream attach function
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
тАО08-06-2008 05:06 AM
тАО08-06-2008 05:06 AM
We are migrating our application from hp-ux 11.0 PA to 11.23 IPF. We are getting the below error while compiling.
class "std::basic_ofstream
logDest.attach(2);
^
( note : logDest has been declared as
ofstream logDest; )
I found that the standard C++ runtime doesnot have anymore the attach member function for the class std::basic_ofstream.
Could anybody let me know the altarnative functionality, which works same as "attach"?.
Solved! Go to Solution.
- Tags:
- -AA
- basic_ofstream
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-06-2008 06:22 PM
тАО08-06-2008 06:22 PM
SolutionThere is a non-Standard replacement for attach, so it isn't mentioned in the porting page:
http://h21007.www2.hp.com/portal/site/dspp/menuitem.863c3e4cbcdc3f3515b49c108973a801/?ciid=eb08b3f1eee02110b3f1eee02110275d6e10RCRD
It does mention detach is missing.
To do ofstream::attach you can do following overloaded extension to open:
void open(int __fd, char_type *__buf=0,
streamsize __n=_RWSTD_DEFAULT_BUFSIZE)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-13-2008 11:01 PM
тАО08-13-2008 11:01 PM
Re: class "std::basic_ofstream attach function
Just a confirmation...To attach the STDOUT to logDest, I am writing code as below. Is it rite?
ofstream logDest;
logDest.open(1, 0, _RWSTD_DEFAULT_BUFSIZE);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-13-2008 11:41 PM
тАО08-13-2008 11:41 PM
Re: class "std::basic_ofstream attach function
Well, I would take the defaults and just use:
#include
logDest.open(STDOUT_FILENO);
If you aren't using "<< endl" everywhere, you might want your buffer even bigger.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-15-2008 02:29 PM
тАО08-15-2008 02:29 PM
Re: class "std::basic_ofstream attach function
http://forums.itrc.hp.com/service/forums/helptips.do?#33
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-18-2008 05:27 AM
тАО08-18-2008 05:27 AM
Re: class "std::basic_ofstream attach function
Thanks for the response.
Some more question I have for you
1: After attaching with logDest.open, how do you close the same. Actually in my code depending on some condition I am attaching it to either STDOUT or STDERR. So once I am done with the work, I need to close the same. How would you know logDest is attached to what, and correspondingly close the same.?
=======================================
2 : My application is getting core dump, while I stopping it. The gdb is not showing much info. Below is the gdb back trace of the same.
HP gdb 5.7 for HP Itanium (32 or 64 bit) and target HP-UX 11.2x.
Copyright 1986 - 2001 Free Software Foundation, Inc.
Hewlett-Packard Wildebeest 5.7 (based on GDB) is covered by the
GNU General Public License. Type "show copying" to see the conditions to
change it and/or distribute copies. Type "show warranty" for warranty/support.
..
Core was generated by `SCHEDULER'.
Program terminated with signal 6, Aborted.
#0 0xc00000000029da30:0 in kill+0x30 () from /usr/lib/hpux64/libc.so.1
(gdb) bt
#0 0xc00000000029da30:0 in kill+0x30 () from /usr/lib/hpux64/libc.so.1
#1 0xc0000000001c1bf0:0 in raise+0x30 () from /usr/lib/hpux64/libc.so.1
#2 0xc00000000025f610:0 in abort+0x190 () from /usr/lib/hpux64/libc.so.1
#3 0xc0000000018c5910:0 in std::terminate()+0x50 ()
from /usr/lib/hpux64/libCsup.so.1
#4 0xc0000000018ef520:0 in __cxxTerm+0x60 () from /usr/lib/hpux64/libCsup.so.1
#5 0xc0000000002072a0:0 in __exit_handler+0xa0 ()
from /usr/lib/hpux64/libc.so.1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-18-2008 08:40 PM
тАО08-18-2008 08:40 PM
Re: class "std::basic_ofstream attach function
That's the problem. It may close it more than once. I.e. you can't ever close that file. You can just flush it.
>So once I am done with the work, I need to close the same. How would you know logDest is attached to what, and correspondingly close the same?
Unfortunately there is no provision for doing that. :-(
So you need to use dup(2) to make a copy of STDOUT or STDERR and then it can be closed:
#include
int fd_file = dup(STDOUT_FILENO);
logDest.open(fd_file);
>2: My application is getting core dump, while I stopping it.
You are doing a throw out of a destructor that isn't caught, during static destruction. This is illegal, 15.5.1(1). In gdb, you need to use "catch throw" just before you exit, so you can catch it.
I'm not sure if it is due to the problem in 1) above?
- Tags:
- throw
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-19-2008 01:13 AM
тАО08-19-2008 01:13 AM
Re: class "std::basic_ofstream attach function
1 : Our application was dumping core due to close function call. In our application we were calling close like below
logDest.close();
I commented it and we are not getting the core !.
2 : I am getting compiler error, when I try to close with 1 argument as below
error #2140: too many arguments in function call
SYSLOG::logDest.close(STDOUT_FILENO);
^
3 : Is it OK, if you donot close, if you are done with the work?.
You said
int fd_file = dup(STDOUT_FILENO);
logDest.open(fd_file);
Againg open, after dup??? ( there is no close call??)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-19-2008 02:00 AM
тАО08-19-2008 02:00 AM
Re: class "std::basic_ofstream attach function
Ok. You can do that or call dup(2).
>2: I am getting compiler error, when I try to close with 1 argument as below
SYSLOG::logDest.close(STDOUT_FILENO);
Why would you think that works? If it was that easy, I would have mentioned it. :-)
>3: Is it OK, if you do not close, if you are done with the work?
For stderr and stdout, they are never closed. But you should flush them.
>You said
>int fd_file = dup(STDOUT_FILENO);
>logDest.open(fd_file);
>Again open, after dup??? (there is no close call??)
Basically, replace that open by dup(2) then open. If you use dup(2), you can leave that close call there.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-19-2008 03:40 AM
тАО08-19-2008 03:40 AM
Re: class "std::basic_ofstream attach function
I and Sushant work in the same team,
The same piece of code is running fine on HP-UX 11.0, Can you please let us know if in the old versions you were ignoring the close call on STDIN and STDERR