'Unable to stop a C program with infinite loop and printf within on macOS

#include <stdio.h>
int main(void) {
    while(1) {
        printf("!");
    }
    return 0;
}

This is my program. When I run it in the terminal, I can't stop it in any way (ctrl-c, ctrl-z, ctrl-\. ...), and the terminal just blocks. Then I have to force quit the entire terminal. Is there a better way to stop it? (My system is macOS Monterey 12.2.1 Intel.)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source