News for hackers. Stuff that matters.
Re:Migrating the main Zig repository from GitHub to Codeberg by Veserv on Thursday November 27, 2025 @12:09AM (#46065894)
The original loop is:

while (time() != timeout) {;}

The fixed loop is:

while (time() < timeout) {;}

Re:Migrating the main Zig repository from GitHub to Codeberg by dpkirchner on Thursday November 27, 2025 @12:28AM (#46065996)
I see. I did not realize SECONDS was a built in bash variable.
Re:Migrating the main Zig repository from GitHub to Codeberg by nh2 on Thursday November 27, 2025 @01:08AM (#46066220)
It is still not a proper fix. It is still busy-looping 100% CPU.

Given that Github Actions is quite popular, probably wasting large amount of energy.

But probably good at generating billable Actions minutes.

One can only hope that not many people use sleeps to handle their CI race conditions, as that itself is also not a proper fix.

Re:Migrating the main Zig repository from GitHub to Codeberg by magicalhippo on Thursday November 27, 2025 @01:40AM (#46066405)
Clearly the job for a microservice. Accept number of seconds to wait as url, return content after that many seconds. Then just use curl in runner.
Re:Migrating the main Zig repository from GitHub to Codeberg by xp84 on Thursday November 27, 2025 @02:30AM (#46066688)
Brb founding a SaaS startup. I’ll call it cloudsleep dot io of course. After our Series B I’ll buy the .com.

Only task to do before lining up investors is how can I weave AI into our product?

Re:Migrating the main Zig repository from GitHub to Codeberg by debugnik on Thursday November 27, 2025 @03:29AM (#46067055)
Describe the task you're waiting for as text, and let an LLM pick the number of seconds for each request. More expensive the better model you clearly need for this. There, your AI pitch.
Re:Migrating the main Zig repository from GitHub to Codeberg by xp84 on Thursday November 27, 2025 @02:46PM (#46072628)
Excellent, welcome aboard, Chief Product Officer!
Re:Migrating the main Zig repository from GitHub to Codeberg by wmanley on Thursday November 27, 2025 @02:41AM (#46066755)
Retries won’t work in that case. Would be better to have two endpoints: get the time in x seconds and wait until time passed. That way retrying the wait endpoint will work fine and if time hasn’t elapsed it can just curl itself with the same arguments.
Re:Migrating the main Zig repository from GitHub to Codeberg by dpkirchner on Thursday November 27, 2025 @09:05AM (#46069371)
If you have curl (but not sleep) sure, but if not maybe you can use bash's wacky /dev/tcp. The microservice could listen on ports 1 through 64k to let you specify how many seconds to sleep.
Re:Migrating the main Zig repository from GitHub to Codeberg by dpkirchner on Thursday November 27, 2025 @09:13AM (#46069454)
Yeah, definitely not a proper fix.

Maybe a more serious fix is something like "read -t $N". If you think stdin might not be usable (like maybe it will close prematurely) this option won't work, but maybe you can open an anonymous FD and read from it instead.

Re:Migrating the main Zig repository from GitHub to Codeberg by qhwudbebd on Friday November 28, 2025 @04:01AM (#46076920)

    while wait && [[ $SECONDS -lt $1 ]]; do
      read -t $(($1 - SECONDS))
    done <><(:)
although if you're not too concerned about finishing early if a signal interrupts, probably

    { wait; read -t $1; } <><(:)
would be fine. You want the wait because otherwise bash won't reap the zombie from the process substitution until after the read times out.

Interestingly, it does reap on a blocked read without -t, so potentially the behaviour on -t would be considered a bug rather than as-designed.

There's also a loadable sleep builtin supplied with bash which calls into the internal fsleep() so should be reliable and without forking.

Re:Migrating the main Zig repository from GitHub to Codeberg by nh2 on Friday November 28, 2025 @01:01PM (#46081043)
It's just all hacks. It should use `sleep`, period.

Sleeping is an OS scheduling task. Use the OS syscall that does that.

As is suggested on the Github issue that Microsoft has been ignoring for half a year.

Re:Migrating the main Zig repository from GitHub to Codeberg by xp84 on Thursday November 27, 2025 @02:28AM (#46066677)
Me neither. I am over 40 and did not know this. Feels good to learn something today, in an unexpected place!