comparison seobeo/tests/seobeo_sigpipe_test.c @ 223:0e7b9464248d hg-web

[hg-web] Add browser route regression coverage
author MrJuneJune <me@mrjunejune.com>
date Sun, 02 Aug 2026 10:07:40 -0700
parents
children
comparison
equal deleted inserted replaced
222:a8d6435dc021 223:0e7b9464248d
1 #include "seobeo/seobeo.h"
2
3 #include <signal.h>
4 #include <stdlib.h>
5 #include <sys/socket.h>
6
7 int main(void)
8 {
9 Seobeo_Handle *server =
10 Seobeo_Stream_Handle_Server_Create("127.0.0.1", "0");
11 if (!server)
12 return 1;
13
14 raise(SIGPIPE);
15 Seobeo_Handle_Destroy(server);
16
17 int sockets[2];
18 if (socketpair(AF_UNIX, SOCK_STREAM, 0, sockets) != 0)
19 return 1;
20
21 Seobeo_Handle handle = {0};
22 handle.socket = sockets[0];
23 handle.write_buffer_capacity = 64;
24 handle.write_buffer = malloc(handle.write_buffer_capacity);
25 if (!handle.write_buffer)
26 return 1;
27
28 close(sockets[1]);
29 if (Seobeo_Handle_Queue(&handle, (const uint8 *)"closed", 6) != 0)
30 return 1;
31
32 int result = Seobeo_Handle_Flush(&handle);
33 close(sockets[0]);
34 free(handle.write_buffer);
35 return result < 0 ? 0 : 1;
36 }