]>
Commit | Line | Data |
---|---|---|
4216708a | 1 | // { dg-require-namedlocale "en_US.ISO8859-1" } |
34f4edf8 MM |
2 | // { dg-require-fork "" } |
3 | // { dg-require-mkfifo "" } | |
4 | ||
2f228199 PC |
5 | // 2004-04-16 Petur Runolfsson <peturr02@ru.is> |
6 | ||
83ffe9cd | 7 | // Copyright (C) 2004-2023 Free Software Foundation, Inc. |
2f228199 PC |
8 | // |
9 | // This file is part of the GNU ISO C++ Library. This library is free | |
10 | // software; you can redistribute it and/or modify it under the | |
11 | // terms of the GNU General Public License as published by the | |
748086b7 | 12 | // Free Software Foundation; either version 3, or (at your option) |
2f228199 PC |
13 | // any later version. |
14 | ||
15 | // This library is distributed in the hope that it will be useful, | |
16 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | // GNU General Public License for more details. | |
19 | ||
20 | // You should have received a copy of the GNU General Public License along | |
748086b7 JJ |
21 | // with this library; see the file COPYING3. If not see |
22 | // <http://www.gnu.org/licenses/>. | |
2f228199 PC |
23 | |
24 | #include <fstream> | |
25 | #include <locale> | |
debac9f4 | 26 | #include <cstdlib> |
2f228199 PC |
27 | #include <unistd.h> |
28 | #include <signal.h> | |
29 | #include <fcntl.h> | |
30 | #include <sys/types.h> | |
31 | #include <sys/stat.h> | |
9339bda8 | 32 | |
2f228199 PC |
33 | #include <testsuite_hooks.h> |
34 | ||
35 | // libstdc++/14975 | |
9339bda8 | 36 | bool test01() |
2f228199 PC |
37 | { |
38 | using namespace std; | |
39 | using namespace __gnu_test; | |
118c8424 | 40 | bool test = true; |
2f228199 | 41 | |
4216708a | 42 | locale loc_us = locale(ISO_8859(1,en_US)); |
2f228199 PC |
43 | |
44 | const char* name = "tmp_14975-2"; | |
45 | ||
46 | signal(SIGPIPE, SIG_IGN); | |
47 | ||
48 | unlink(name); | |
34f4edf8 | 49 | mkfifo(name, S_IRWXU); |
8f1032c1 MM |
50 | semaphore s1; |
51 | ||
2f228199 | 52 | int child = fork(); |
118c8424 | 53 | test &= bool( child != -1 ); |
2f228199 PC |
54 | |
55 | if (child == 0) | |
56 | { | |
8f1032c1 MM |
57 | { |
58 | filebuf fbin; | |
59 | fbin.open(name, ios_base::in); | |
60 | } | |
9339bda8 | 61 | s1.signal(); |
2f228199 PC |
62 | exit(0); |
63 | } | |
64 | ||
65 | wfilebuf fb; | |
66 | fb.pubimbue(loc_us); | |
2f228199 | 67 | wfilebuf* ret = fb.open(name, ios_base::out); |
118c8424 PC |
68 | test &= bool( ret != 0 ); |
69 | test &= bool( fb.is_open() ); | |
2f228199 | 70 | |
9339bda8 | 71 | s1.wait(); |
2f228199 PC |
72 | |
73 | try | |
74 | { | |
75 | fb.sputc(L'a'); | |
76 | fb.sputc(L'b'); | |
77 | fb.pubimbue(locale::classic()); | |
78 | fb.sputc(L'c'); | |
79 | fb.close(); | |
80 | } | |
81 | catch (std::exception&) | |
82 | { | |
83 | } | |
9339bda8 PC |
84 | |
85 | return test; | |
2f228199 PC |
86 | } |
87 | ||
88 | int main() | |
89 | { | |
9339bda8 | 90 | return !test01(); |
2f228199 | 91 | } |