[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / compiler-rt / test / sanitizer_common / TestCases / NetBSD / paccept.cpp
blob7d2eb4e85596f4b35e86588a4d82a7da97071aa5
1 // RUN: %clangxx -O0 -g %s -o %t && %run %t
3 #include <netinet/in.h>
4 #include <sys/socket.h>
5 #include <sys/wait.h>
6 #include <signal.h>
7 #include <stdlib.h>
8 #include <unistd.h>
10 int main(void) {
11 int child;
12 int fd, sfd;
13 socklen_t len;
14 struct sockaddr_in server = {}, client = {};
15 sigset_t set;
17 child = fork();
18 if (child == 0) {
19 fd = socket(AF_INET, SOCK_STREAM, 0);
20 if (fd == -1)
21 _exit(1);
23 server.sin_family = AF_INET;
24 server.sin_addr.s_addr = INADDR_ANY;
25 server.sin_port = htons(2222);
27 if (connect(fd, (struct sockaddr *)&server, sizeof(server)) == -1)
28 _exit(1);
30 close(fd);
32 _exit(0);
35 fd = socket(AF_INET, SOCK_STREAM, 0);
36 if (fd == -1) {
37 kill(child, SIGKILL);
38 wait(NULL);
39 exit(1);
42 server.sin_family = AF_INET;
43 server.sin_addr.s_addr = INADDR_ANY;
44 server.sin_port = htons(2222);
46 if (bind(fd, (const struct sockaddr *)&server, sizeof(server)) == -1) {
47 kill(child, SIGKILL);
48 wait(NULL);
49 exit(1);
52 listen(fd, 3);
54 if (sigemptyset(&set) == -1) {
55 kill(child, SIGKILL);
56 wait(NULL);
57 exit(1);
60 len = sizeof(client);
61 sfd = paccept(fd, (struct sockaddr *)&client, &len, &set, SOCK_NONBLOCK);
62 if (sfd == -1) {
63 kill(child, SIGKILL);
64 wait(NULL);
65 exit(1);
68 wait(NULL);
70 close(sfd);
71 close(fd);
73 return 0;