User Tools

Site Tools


os_cp:pipes_signals

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
os_cp:pipes_signals [2023/04/25 21:56] – [Pipes & FIFOs] jkonczakos_cp:pipes_signals [2023/05/09 21:18] (current) – [Shared memory] jkonczak
Line 128: Line 128:
 ===== Signals ===== ===== Signals =====
  
-Disclaimer: these materials contain the very basics signals.  +Disclaimer: these materials contain the very basics of signals.  
-For a comprehensive information on signals, see the+For comprehensive informations, see the
 [[https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_04|POSIX standard]]. [[https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_04|POSIX standard]].
  
Line 430: Line 430:
 To ensure that the file is large enough, one can use the following functions: To ensure that the file is large enough, one can use the following functions:
   * ''[[https://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html|ftruncate]]'' <html><span style="float:right"><small>Needs header: <code>unistd.h</code></small></span></html> resizes file to a given size. \\ Whenever the file is larger it is truncated.   * ''[[https://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html|ftruncate]]'' <html><span style="float:right"><small>Needs header: <code>unistd.h</code></small></span></html> resizes file to a given size. \\ Whenever the file is larger it is truncated.
-  * ''[[https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_fallocate.html|posix_fallocate]]'' <html><span style="float:right"><small>Needs header: <code>fcntl.h</code></small></span></html> ensures that the file at least of a given size. \\ Whenever the file is larger it is left unchanged. \\ <small>Warning: ''posix_fallocate'' is guaranteed to work for ordinary files. Result of using ''posix_fallocate'' on shared memory object is undefined.</small>+  * ''[[https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_fallocate.html|posix_fallocate]]'' <html><span style="float:right"><small>Needs header: <code>fcntl.h</code></small></span></html> ensures that the file at least of a given size. \\ Whenever the file is larger it is left unchanged. \\ <small>Warning: ''posix_fallocate'' is guaranteed to work for ordinary files. The result of using ''posix_fallocate'' on a shared memory object is undefined.</small>
  
 To clean up the memory mapping, one has to use the To clean up the memory mapping, one has to use the
Line 443: Line 443:
  
 <html><p style="text-align: center"><object id="svg-object" data="/jkonczak/_media/os_cp:mmap.svg" type="image/svg+xml"></object></p></html> <html><p style="text-align: center"><object id="svg-object" data="/jkonczak/_media/os_cp:mmap.svg" type="image/svg+xml"></object></p></html>
 +
 +**To compile programs that use ''shm_open'' with older glibc versions, one must add ''-lrt'' to compile options.**
  
 ~~Exercise.#~~ ~~Exercise.#~~
Line 499: Line 501:
  
     char c, text[1022] = {0};     char c, text[1022] = {0};
-    scanf("%[^\n]1021", text);+    scanf("%1021[^\n]", text);
     do { // this reads all remaining characters in this line including '\n'     do { // this reads all remaining characters in this line including '\n'
       c = getchar();       c = getchar();
Line 577: Line 579:
 } }
 </code> </code>
- 
-//one must use msync() 
-//to sync data to disk 
  
 ~~META: ~~META:
os_cp/pipes_signals.1682459761.txt.gz · Last modified: (external edit)