<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: class &amp;quot;std::basic_ofstream  attach function in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/class-quot-std-basic-ofstream-attach-function/m-p/4247112#M687682</link>
    <description>Dennis,&lt;BR /&gt;Thanks for the response.&lt;BR /&gt;Some more question I have for you&lt;BR /&gt;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.?&lt;BR /&gt;=======================================&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;HP gdb 5.7 for HP Itanium (32 or 64 bit) and target HP-UX 11.2x.&lt;BR /&gt;Copyright 1986 - 2001 Free Software Foundation, Inc.&lt;BR /&gt;Hewlett-Packard Wildebeest 5.7 (based on GDB) is covered by the&lt;BR /&gt;GNU General Public License. Type "show copying" to see the conditions to&lt;BR /&gt;change it and/or distribute copies. Type "show warranty" for warranty/support.&lt;BR /&gt;..&lt;BR /&gt;Core was generated by `SCHEDULER'.&lt;BR /&gt;Program terminated with signal 6, Aborted.&lt;BR /&gt;&lt;BR /&gt;#0  0xc00000000029da30:0 in kill+0x30 () from /usr/lib/hpux64/libc.so.1&lt;BR /&gt;(gdb) bt&lt;BR /&gt;#0  0xc00000000029da30:0 in kill+0x30 () from /usr/lib/hpux64/libc.so.1&lt;BR /&gt;#1  0xc0000000001c1bf0:0 in raise+0x30 () from /usr/lib/hpux64/libc.so.1&lt;BR /&gt;#2  0xc00000000025f610:0 in abort+0x190 () from /usr/lib/hpux64/libc.so.1&lt;BR /&gt;#3  0xc0000000018c5910:0 in std::terminate()+0x50 ()&lt;BR /&gt;   from /usr/lib/hpux64/libCsup.so.1&lt;BR /&gt;#4  0xc0000000018ef520:0 in __cxxTerm+0x60 () from /usr/lib/hpux64/libCsup.so.1&lt;BR /&gt;#5  0xc0000000002072a0:0 in __exit_handler+0xa0 ()&lt;BR /&gt;   from /usr/lib/hpux64/libc.so.1&lt;BR /&gt;</description>
    <pubDate>Mon, 18 Aug 2008 12:27:35 GMT</pubDate>
    <dc:creator>sushant keerti</dc:creator>
    <dc:date>2008-08-18T12:27:35Z</dc:date>
    <item>
      <title>class "std::basic_ofstream  attach function</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/class-quot-std-basic-ofstream-attach-function/m-p/4247107#M687677</link>
      <description>Hi,&lt;BR /&gt;We are migrating our application from hp-ux 11.0 PA to 11.23 IPF. We are getting the below error while compiling.&lt;BR /&gt;class "std::basic_ofstream&lt;CHAR&gt;&amp;gt;" has no member "attach"&lt;BR /&gt;                    logDest.attach(2); &lt;BR /&gt;                            ^&lt;BR /&gt; &lt;BR /&gt;( note : logDest has been declared as &lt;BR /&gt;ofstream logDest; )&lt;BR /&gt;I found that the standard C++ runtime doesnot have anymore the attach member function for the class std::basic_ofstream. &lt;BR /&gt;&lt;BR /&gt;Could anybody let me know the altarnative functionality, which works same as "attach"?.&lt;BR /&gt;&lt;BR /&gt;&lt;/CHAR&gt;</description>
      <pubDate>Wed, 06 Aug 2008 12:06:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/class-quot-std-basic-ofstream-attach-function/m-p/4247107#M687677</guid>
      <dc:creator>sushant keerti</dc:creator>
      <dc:date>2008-08-06T12:06:10Z</dc:date>
    </item>
    <item>
      <title>Re: class "std::basic_ofstream  attach function</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/class-quot-std-basic-ofstream-attach-function/m-p/4247108#M687678</link>
      <description>cfront's fstream::attach &amp;amp; detach aren't Standard and don't exist in -AA mode.&lt;BR /&gt;&lt;BR /&gt;There is a non-Standard replacement for attach, so it isn't mentioned in the porting page:&lt;BR /&gt;&lt;A href="http://h21007.www2.hp.com/portal/site/dspp/menuitem.863c3e4cbcdc3f3515b49c108973a801/?ciid=eb08b3f1eee02110b3f1eee02110275d6e10RCRD" target="_blank"&gt;http://h21007.www2.hp.com/portal/site/dspp/menuitem.863c3e4cbcdc3f3515b49c108973a801/?ciid=eb08b3f1eee02110b3f1eee02110275d6e10RCRD&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;It does mention detach is missing.&lt;BR /&gt;&lt;BR /&gt;To do ofstream::attach you can do following overloaded extension to open:&lt;BR /&gt;void open(int  __fd, char_type *__buf=0,&lt;BR /&gt;               streamsize __n=_RWSTD_DEFAULT_BUFSIZE)</description>
      <pubDate>Thu, 07 Aug 2008 01:22:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/class-quot-std-basic-ofstream-attach-function/m-p/4247108#M687678</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-08-07T01:22:30Z</dc:date>
    </item>
    <item>
      <title>Re: class "std::basic_ofstream  attach function</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/class-quot-std-basic-ofstream-attach-function/m-p/4247109#M687679</link>
      <description>Dennis,&lt;BR /&gt;Just a confirmation...To attach the STDOUT to logDest, I am writing code as below. Is it rite?&lt;BR /&gt;&lt;BR /&gt;ofstream logDest;&lt;BR /&gt;logDest.open(1, 0, _RWSTD_DEFAULT_BUFSIZE);</description>
      <pubDate>Thu, 14 Aug 2008 06:01:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/class-quot-std-basic-ofstream-attach-function/m-p/4247109#M687679</guid>
      <dc:creator>sushant keerti</dc:creator>
      <dc:date>2008-08-14T06:01:46Z</dc:date>
    </item>
    <item>
      <title>Re: class "std::basic_ofstream  attach function</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/class-quot-std-basic-ofstream-attach-function/m-p/4247110#M687680</link>
      <description>&amp;gt;To attach the STDOUT to logDest, I am writing code as below.&lt;BR /&gt;&lt;BR /&gt;Well, I would take the defaults and just use:&lt;BR /&gt;#include &lt;UNISTD.H&gt;&lt;BR /&gt;logDest.open(STDOUT_FILENO);&lt;BR /&gt;&lt;BR /&gt;If you aren't using "&amp;lt;&amp;lt; endl" everywhere, you might want your buffer even bigger.&lt;/UNISTD.H&gt;</description>
      <pubDate>Thu, 14 Aug 2008 06:41:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/class-quot-std-basic-ofstream-attach-function/m-p/4247110#M687680</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-08-14T06:41:47Z</dc:date>
    </item>
    <item>
      <title>Re: class "std::basic_ofstream  attach function</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/class-quot-std-basic-ofstream-attach-function/m-p/4247111#M687681</link>
      <description>If you have gotten the answers you needed, please read the following about assigning points:&lt;BR /&gt;&lt;A href="http://forums.itrc.hp.com/service/forums/helptips.do?#33" target="_blank"&gt;http://forums.itrc.hp.com/service/forums/helptips.do?#33&lt;/A&gt;</description>
      <pubDate>Fri, 15 Aug 2008 21:29:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/class-quot-std-basic-ofstream-attach-function/m-p/4247111#M687681</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-08-15T21:29:24Z</dc:date>
    </item>
    <item>
      <title>Re: class "std::basic_ofstream  attach function</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/class-quot-std-basic-ofstream-attach-function/m-p/4247112#M687682</link>
      <description>Dennis,&lt;BR /&gt;Thanks for the response.&lt;BR /&gt;Some more question I have for you&lt;BR /&gt;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.?&lt;BR /&gt;=======================================&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;HP gdb 5.7 for HP Itanium (32 or 64 bit) and target HP-UX 11.2x.&lt;BR /&gt;Copyright 1986 - 2001 Free Software Foundation, Inc.&lt;BR /&gt;Hewlett-Packard Wildebeest 5.7 (based on GDB) is covered by the&lt;BR /&gt;GNU General Public License. Type "show copying" to see the conditions to&lt;BR /&gt;change it and/or distribute copies. Type "show warranty" for warranty/support.&lt;BR /&gt;..&lt;BR /&gt;Core was generated by `SCHEDULER'.&lt;BR /&gt;Program terminated with signal 6, Aborted.&lt;BR /&gt;&lt;BR /&gt;#0  0xc00000000029da30:0 in kill+0x30 () from /usr/lib/hpux64/libc.so.1&lt;BR /&gt;(gdb) bt&lt;BR /&gt;#0  0xc00000000029da30:0 in kill+0x30 () from /usr/lib/hpux64/libc.so.1&lt;BR /&gt;#1  0xc0000000001c1bf0:0 in raise+0x30 () from /usr/lib/hpux64/libc.so.1&lt;BR /&gt;#2  0xc00000000025f610:0 in abort+0x190 () from /usr/lib/hpux64/libc.so.1&lt;BR /&gt;#3  0xc0000000018c5910:0 in std::terminate()+0x50 ()&lt;BR /&gt;   from /usr/lib/hpux64/libCsup.so.1&lt;BR /&gt;#4  0xc0000000018ef520:0 in __cxxTerm+0x60 () from /usr/lib/hpux64/libCsup.so.1&lt;BR /&gt;#5  0xc0000000002072a0:0 in __exit_handler+0xa0 ()&lt;BR /&gt;   from /usr/lib/hpux64/libc.so.1&lt;BR /&gt;</description>
      <pubDate>Mon, 18 Aug 2008 12:27:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/class-quot-std-basic-ofstream-attach-function/m-p/4247112#M687682</guid>
      <dc:creator>sushant keerti</dc:creator>
      <dc:date>2008-08-18T12:27:35Z</dc:date>
    </item>
    <item>
      <title>Re: class "std::basic_ofstream  attach function</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/class-quot-std-basic-ofstream-attach-function/m-p/4247113#M687683</link>
      <description>&amp;gt;1: After attaching with logDest.open, how do you close the same.&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;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?&lt;BR /&gt;&lt;BR /&gt;Unfortunately there is no provision for doing that.  :-(&lt;BR /&gt;So you need to use dup(2) to make a copy of STDOUT or STDERR and then it can be closed:&lt;BR /&gt;&lt;BR /&gt;#include &lt;UNISTD.H&gt;&lt;BR /&gt;int fd_file = dup(STDOUT_FILENO);&lt;BR /&gt;logDest.open(fd_file);&lt;BR /&gt;&lt;BR /&gt;&amp;gt;2: My application is getting core dump, while I stopping it.&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;I'm not sure if it is due to the problem in 1) above?&lt;/UNISTD.H&gt;</description>
      <pubDate>Tue, 19 Aug 2008 03:40:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/class-quot-std-basic-ofstream-attach-function/m-p/4247113#M687683</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-08-19T03:40:49Z</dc:date>
    </item>
    <item>
      <title>Re: class "std::basic_ofstream  attach function</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/class-quot-std-basic-ofstream-attach-function/m-p/4247114#M687684</link>
      <description>Dennis,&lt;BR /&gt;1 : Our application was dumping core due to close function call. In our application we were calling close like below&lt;BR /&gt;&lt;BR /&gt;logDest.close();&lt;BR /&gt;&lt;BR /&gt;I commented it and we are not getting the core !.&lt;BR /&gt;&lt;BR /&gt;2 : I am getting compiler error, when I try to close with 1 argument as below&lt;BR /&gt;&lt;BR /&gt; error #2140: too many arguments in function call&lt;BR /&gt;      SYSLOG::logDest.close(STDOUT_FILENO);&lt;BR /&gt;                            ^&lt;BR /&gt;&lt;BR /&gt;3 : Is it OK, if you donot close, if you are done with the work?.&lt;BR /&gt;You said &lt;BR /&gt;int fd_file = dup(STDOUT_FILENO);&lt;BR /&gt;  logDest.open(fd_file);&lt;BR /&gt;            &lt;BR /&gt;Againg open, after dup??? ( there is no close call??)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 19 Aug 2008 08:13:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/class-quot-std-basic-ofstream-attach-function/m-p/4247114#M687684</guid>
      <dc:creator>sushant keerti</dc:creator>
      <dc:date>2008-08-19T08:13:12Z</dc:date>
    </item>
    <item>
      <title>Re: class "std::basic_ofstream  attach function</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/class-quot-std-basic-ofstream-attach-function/m-p/4247115#M687685</link>
      <description>&amp;gt;I commented it and we are not getting the core!&lt;BR /&gt;&lt;BR /&gt;Ok.  You can do that or call dup(2).&lt;BR /&gt;&lt;BR /&gt;&amp;gt;2: I am getting compiler error, when I try to close with 1 argument as below&lt;BR /&gt;SYSLOG::logDest.close(STDOUT_FILENO);&lt;BR /&gt;&lt;BR /&gt;Why would you think that works?  If it was that easy, I would have mentioned it.  :-)&lt;BR /&gt;&lt;BR /&gt;&amp;gt;3: Is it OK, if you do not close, if you are done with the work?&lt;BR /&gt;&lt;BR /&gt;For stderr and stdout, they are never closed.  But you should flush them.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;You said&lt;BR /&gt;&amp;gt;int fd_file = dup(STDOUT_FILENO);&lt;BR /&gt;&amp;gt;logDest.open(fd_file);&lt;BR /&gt;&amp;gt;Again open, after dup??? (there is no close call??)&lt;BR /&gt;&lt;BR /&gt;Basically, replace that open by dup(2) then open.  If you use dup(2), you can leave that close call there.</description>
      <pubDate>Tue, 19 Aug 2008 09:00:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/class-quot-std-basic-ofstream-attach-function/m-p/4247115#M687685</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-08-19T09:00:51Z</dc:date>
    </item>
    <item>
      <title>Re: class "std::basic_ofstream  attach function</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/class-quot-std-basic-ofstream-attach-function/m-p/4247116#M687686</link>
      <description>Dennis&lt;BR /&gt;I and Sushant work in the same team,&lt;BR /&gt;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</description>
      <pubDate>Tue, 19 Aug 2008 10:40:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/class-quot-std-basic-ofstream-attach-function/m-p/4247116#M687686</guid>
      <dc:creator>Kishan Rajagopal</dc:creator>
      <dc:date>2008-08-19T10:40:08Z</dc:date>
    </item>
    <item>
      <title>Re: class "std::basic_ofstream  attach function</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/class-quot-std-basic-ofstream-attach-function/m-p/4247117#M687687</link>
      <description>Sorry forgot to mention the compiler we were using,&lt;BR /&gt;Our application was running on HP-UX11.0 with aCC: HP ANSI C++ B3910B A.03.31 compiler.&lt;BR /&gt;Does the exe generated in this environment ignore the close call on STDIN and STDERR? As we are not getting any core file when we are bringing down the aplication in this environment.&lt;BR /&gt;</description>
      <pubDate>Tue, 19 Aug 2008 10:55:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/class-quot-std-basic-ofstream-attach-function/m-p/4247117#M687687</guid>
      <dc:creator>Kishan Rajagopal</dc:creator>
      <dc:date>2008-08-19T10:55:16Z</dc:date>
    </item>
    <item>
      <title>Re: class "std::basic_ofstream  attach function</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/class-quot-std-basic-ofstream-attach-function/m-p/4247118#M687688</link>
      <description>&amp;gt;The same piece of code is running fine on HP-UX 11.00, Can you please let us know if in the old versions you were ignoring the close call on STDIN and STDERR&lt;BR /&gt;&lt;BR /&gt;If you were using -AP and attach and detach, it wasn't the same code.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;As we are not getting any core file&lt;BR /&gt;&lt;BR /&gt;If you were using -AP, iostream errors don't throw.</description>
      <pubDate>Tue, 19 Aug 2008 18:22:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/class-quot-std-basic-ofstream-attach-function/m-p/4247118#M687688</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-08-19T18:22:26Z</dc:date>
    </item>
  </channel>
</rss>

