Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need the three-argument form of <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/open.html" rel="noreferrer"><code>open()</code></a> when you specify O_CREAT. When you omit the third argument, <code>open()</code> uses whatever value happens to be on the stack where the third argument was expected; this is seldom a coherent set of permissions (in your example, it appears that decimal 12 = octal 014 was on the stack).</p> <p>The third argument is the permissions on the file - which will be modified by the <code>umask()</code> value.</p> <pre><code>int fd2 = open("/tmp/test.svg", O_RDWR | O_CREAT, S_IRUSR | S_IRGRP | S_IROTH); </code></pre> <p>Note that you can create a file without write permissions (to anyone else, or any other process) while still being able to write to it from the current process. There is seldom a need to use execute bits on files created from a program - unless you are writing a compiler (and '.svg' files are not normally executables!).</p> <p>The S_xxxx flags come from <a href="http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_stat.h.html#tag_13_62" rel="noreferrer"><code>&lt;sys/stat.h&gt;</code></a> and <a href="http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/fcntl.h.html#tag_13_11" rel="noreferrer"><code>&lt;fcntl.h&gt;</code></a> — you can use either header to get the information (but <code>open()</code> itself is declared in <code>&lt;fcntl.h&gt;</code>).</p> <p>Note that the fixed file name and the absence of protective options such as <code>O_EXCL</code> make even the revised <code>open()</code> call somewhat unsafe.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload