Using C on Linux, how can I run a signal handler every time I write data to the buffer using the write () function. The handler will read all the data written to the buffer at runtime.
Sockets support this by activating async mode in the socket file descriptor. On Linux, this is done using fcntl calls:
/* set socket owner (the process that will receive signals) */ fcntl(fd, F_SETOWN, getpid()); /* optional if you want to receive a real-time signal instead of SIGIO */ fnctl(fd, F_SETSIG, signum); /* turn on async mode -- this is the important part which enables signal delivery */ fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_ASYNC);
Use pipe()with O_ASYNC, and you will get SIGIOon the read end of the pipe whenever new data about the pipe.
pipe()
O_ASYNC
SIGIO
100% , , select , . , /. / -.
write() FIFO, pipe ( Ken Bloom), ( mark4o), (.. SIGIO), , raise() . , , .
write()
raise()
, , SIGIO , . , - .
- Linux : - Linux, SIGIO. SIGIO .
, API POSIX AIO, 2.6, , / .
-, - Linux API AIO.
Source: https://habr.com/ru/post/1739018/More articles:Has anyone worked with PowerPlus software? - architecturedynamically getting base url inside js file - javascriptWhen is it safe to do Response.Redirect () without exception? - c #BlackBerry - MainScreen with vertical scroll shortcuts - user-interfaceSupport database design - database-designПолосы: RedirectResolution; Как я могу перенаправить на конкретное мероприятие? - redirectWhen the functions of html attributes and css styles overlap - htmlemacs: why is the cursor position less than the expected value? - emacslinux new / delete, malloc / free large blocks of memory - new-operatorWhy use mysql_real_escape_string, does it hurt to prevent this? - securityAll Articles