Artifact 181b7d4d810e5cdfe23301480693bc49312f3df527b26368e8970c2db8b98304:
- File
src/net.h
— part of check-in
[0dececc6d4]
at
2026-11-19 11:13:30
on branch events
— Ctrl-C cancels the running request, not pic
The first Ctrl-C sets a flag that network waits, retry pauses and the bash tool notice: a running command is aborted through its supervisor and its output kept ("Command aborted"), a provider request stops waiting and is not retried, and the run loop cancels that request the way pic cancel does, leaving other queued requests alone. A second Ctrl-C exits at once and the next run recovers as before. pic also ignores SIGPIPE, so a reader that goes away does not stop a run. (user: dmestas, size: 1605) [annotate] [blame] [check-ins using] [more...]
/* One outgoing connection: TCP, then TLS 1.2 (BearSSL) unless the host is the * loopback address and TLS was not asked for. The only file that includes * BearSSL is net.c, so the TLS library can be replaced there alone. * Every wait is bounded by an idle limit and an overall deadline. */ #ifndef PIC_NET_H #define PIC_NET_H #include <stddef.h> #include <signal.h> /* Set by pic's SIGINT handler (Ctrl-C): network waits give up with * "interrupted" and a running command is aborted. */ extern volatile sig_atomic_t pic_interrupted; typedef struct pic_net pic_net; /* Loads the trust anchors ($SSL_CERT_FILE, else the system bundle), seeds * the TLS random generator and reads the date. NULL with err on failure. */ pic_net *pic_net_new(char *err, size_t cap); void pic_net_free(pic_net *n); /* Connects to host:port within idle_seconds of no progress and * deadline_seconds overall (the deadline also covers later reads and * writes). tls 0 is allowed only for loopback hosts. 0 or -1. */ int pic_net_connect(pic_net *n, const char *host, int port, int tls, int idle_seconds, int deadline_seconds); /* Sends all n bytes (buffered by TLS until the first read). 0 or -1. */ int pic_net_write(pic_net *n, const void *bytes, size_t len); /* > 0 bytes read, 0 at a clean end of stream, -1 on error. */ long pic_net_read(pic_net *n, void *bytes, size_t cap); void pic_net_close(pic_net *n); /* What failed, for a message. */ const char *pic_net_error(const pic_net *n); /* The failure was in TLS: handshake, certificate, host name or protocol. */ int pic_net_tls_failed(const pic_net *n); #endif