curl_multi_wakeup(3)
π curl_multi_wakeup β the "hey bestie wake UP" function (from the curl_multi_wakeup(3) manual, Library Functions Manual, no cap) π
okay so. imagine your curl_multi_poll is sleeping. like fully out cold, waiting for activity or a timeout, just vibing. and you, from a whole other thread, need it to wake up right now. that's this function. it's giving alarm clock energy. β°β¨
πΈ NAME πΈ
curl_multi_wakeup β wake up a sleeping curl_multi_poll call π
β¨ SYNOPSIS β¨
#include <curl/curl.h>
CURLMcode curl_multi_wakeup(CURLM *multi_handle);
π¦ DESCRIPTION π¦
so here's the tea: this function can be called from any thread, and it wakes up a sleeping curl_multi_poll(3) call that is currently (or is about to be) waiting for activity or a timeout. literally just taps it on the shoulder like "girl. get up." π«Ά
and if you call it when there is no curl_multi_poll(3) call happening? it makes the next call return immediately. so it's not wasted, it's just early. iconique. π
important vibe check though β calling this function only guarantees to wake up the current curl_multi_poll(3) call (or the next one, if there's no current one). which means it is possible that multiple calls to this function wake up the same waiting operation. yes, they can pile onto each other. it's fine, it's fine, don't panic. π
also, heads up bestie: this function has no effect on curl_multi_wait(3) calls. zero. nada. that's a different function, okay? π
π PROTOCOLS π
This functionality affects all supported protocols. all of them. every single one. slay. β
π EXAMPLE π
this is the whole two-threads-one-multi-handle situation, and honestly? it ate. π₯
extern int time_to_die(void);
extern int set_something_to_signal_thread_1_to_exit(void);
extern int decide_to_stop_thread1();
int main(void)
{
CURL *easy;
CURLM *multi = curl_multi_init();
int still_running;
easy = curl_easy_init();
/* add the individual easy handle */
curl_multi_add_handle(multi, easy);
/* this is thread 1 */
do {
CURLMcode mresult;
int numfds;
mresult = curl_multi_perform(multi, &still_running);
if(mresult == CURLM_OK) {
/* wait for activity, timeout or wakeup */
mresult = curl_multi_poll(multi, NULL, 0, 10000, &numfds);
}
if(time_to_die())
return 1;
} while(still_running);
curl_multi_remove_handle(multi, easy);
/* this is thread 2 */
if(decide_to_stop_thread1()) {
set_something_to_signal_thread_1_to_exit();
curl_multi_wakeup(multi);
}
}
see how thread 1 is just sitting there in curl_multi_poll minding its business, and thread 2 rolls up and hits curl_multi_wakeup(multi)? that's the whole move. main character behavior from thread 2 honestly. π
π AVAILABILITY π
Added in curl 7.68.0. so if you're on anything older, this function simply does not exist. tragic. π
π RETURN VALUE π
This function returns a CURLMcode indicating success or error.
CURLM_OK (0) means everything was OK. non-zero means an error occurred β see libcurl-errors(3) for the full rundown. β¨
π§ SEE ALSO π§
and that's the page, bestie! π this lil rewrite brought to you by libcurl, dated 2026-10-12, and the original curl_multi_wakeup(3) manual page from the Library Functions Manual β go wake up your poll calls responsibly, ily, bye! ππ¦πΈ
π¦ where this page comes from
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms