Search notes:

libc: alarm

The following example combines alarm() with pause():
#include <stdio.h>
#include <signal.h>
#include <unistd.h>

void sig_alarm(int signum) {
   printf("SIGALRM received\n");
}

int main() {

   signal(SIGALRM, sig_alarm);

   printf("Setting alarm to go off in 3 seconds\n");
   alarm(3);

   printf("Freeze (pause) current process until a signal is delivered\n");
   pause();

   printf("Signal was delivered - pause is over\n");
}
Github repository about-libc, path: /functions/alarm/pause.c
When executed, the program prints:
Setting alarm to go off in 3 seconds
Freeze (pause) current process until a signal is delivered
SIGALRM received
Signal was delivered - pause is over

See also

The Standard C Library
Perl function alarm

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758201062, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/C-C-plus-plus/C/libc/alarm(67): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78