Ah, I found this comment in osprocs.nim:
proc waitForExit*(p: Process, timeout: int = -1): int {.rtl,
extern: "nosp$1", tags: [].}
## waits for the process to finish and returns `p`'s error code.
##
## **Warning**: Be careful when using waitForExit for processes created
without
## poParentStreams because they may fill output buffers, causing deadlock.
##
## On posix, if the process has exited because of a signal, 128 + signal
## number will be returned.
Run
Now I understand. Since there are warnings printed, it's likely the output
buffers are getting filled and causing a deadlock. So what I need to do is
remove warnings by adding `-w` to the aarch64-none-elf-gcc call. Tested it and
it works very well!