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

Next revision
Previous revision
os_cp:pipes_signals [2023/04/18 23:50]
jkonczak utworzono
os_cp:pipes_signals [2023/05/09 23:18] (current)
jkonczak [Shared memory]
Line 120: Line 120:
 \\ \\
 <​small>​ You may do this e.g., by: ''​pipe'',​ ''​fork'',​ in one process: ''​dup2''​ <​small>​ You may do this e.g., by: ''​pipe'',​ ''​fork'',​ in one process: ''​dup2''​
-and ''​exec'',​ in the other process: reading from pipe and changing case.</small>+and ''​exec'',​ in the other process: reading from pipe and changing case. 
 +\\ 
 +The ''​[[https:​//​en.cppreference.com/​w/​c/​string/​byte/​toupper|toupper]]''​ function (available from ''​ctype.h''​) converts a single character to upper case.
  
-~~Exercise.#​~~ Write a program that does ''​ps -eF | sort -nk6''​.+~~Exercise.#​~~ Write a program that does ''​ps -eF | sort -nk6''​.</​small>​
  
 ===== Signals ===== ===== Signals =====
  
-Disclaimer: these materials contain the very basics signals.  +Disclaimer: these materials contain the very basics ​of signals.  
-For 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 428: 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 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 441: 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 497: 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 575: Line 579:
 } }
 </​code>​ </​code>​
- 
-//one must use msync() 
-//to sync data to disk 
  
 ~~META: ~~META:
os_cp/pipes_signals.1681854603.txt.gz · Last modified: 2023/04/18 23:50 (external edit)