Merge from mainline (163495:164578).
[official-gcc/graphite-test-results.git] / libstdc++-v3 / testsuite / 27_io / basic_filebuf / imbue / wchar_t / 14975-2.cc
blobdc1314556d1f591d10fe69fb253c3191d07034a8
1 // { dg-require-namedlocale "en_US" }
2 // { dg-require-fork "" }
3 // { dg-require-mkfifo "" }
5 // 2004-04-16 Petur Runolfsson <peturr02@ru.is>
7 // Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010
8 // Free Software Foundation, Inc.
9 //
10 // This file is part of the GNU ISO C++ Library. This library is free
11 // software; you can redistribute it and/or modify it under the
12 // terms of the GNU General Public License as published by the
13 // Free Software Foundation; either version 3, or (at your option)
14 // any later version.
16 // This library is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
21 // You should have received a copy of the GNU General Public License along
22 // with this library; see the file COPYING3. If not see
23 // <http://www.gnu.org/licenses/>.
25 #include <fstream>
26 #include <locale>
27 #include <cstdlib>
28 #include <unistd.h>
29 #include <signal.h>
30 #include <fcntl.h>
31 #include <sys/types.h>
32 #include <sys/stat.h>
34 // No asserts, avoid leaking the semaphore if a VERIFY fails.
35 #undef _GLIBCXX_ASSERT
37 #include <testsuite_hooks.h>
39 // libstdc++/14975
40 bool test01()
42 using namespace std;
43 using namespace __gnu_test;
44 bool test __attribute__((unused)) = true;
46 locale loc_us = locale("en_US");
48 const char* name = "tmp_14975-2";
50 signal(SIGPIPE, SIG_IGN);
52 unlink(name);
53 mkfifo(name, S_IRWXU);
54 semaphore s1;
56 int child = fork();
57 VERIFY( child != -1 );
59 if (child == 0)
62 filebuf fbin;
63 fbin.open(name, ios_base::in);
65 s1.signal();
66 exit(0);
69 wfilebuf fb;
70 fb.pubimbue(loc_us);
71 wfilebuf* ret = fb.open(name, ios_base::out);
72 VERIFY( ret != 0 );
73 VERIFY( fb.is_open() );
75 s1.wait();
77 try
79 fb.sputc(L'a');
80 fb.sputc(L'b');
81 fb.pubimbue(locale::classic());
82 fb.sputc(L'c');
83 fb.close();
85 catch (std::exception&)
89 return test;
92 int main()
94 return !test01();