This works successfully, as I check the umask afterward by typing

Consider the process tree like an outline. Each node in the outline has a set of attributes. Each node is only able to modify its own attributes. When a child process is created, the attributes from the parent node are copied to the child node.

umask is an attribute of the process. Your process is only able to modify the umask of itself. All children started by that process will then inherit the current umask at the time the child process is invoked. You cannot modify any process that is not the current process (ignore kernel hackery for this discussion).

What you are considering behavior that "works" is the following:

What you are seeing in the terminal is consistent with the outline / attribute analogy. What you are seeing in the perl code is also consistent with the analogy. You are starting a child process (`umask...`), which is inheriting the current umask value of the perl process. Once the child process is complete, the parent continues on, not effected by what the child process did to change its umask attribute.

When the perl process terminates, the parent process that started perl also does not care what perl did to its own umask attribute.

Once you understand that a process is not effected by its children (outside of IPC means), a lot of things become clearer.

--MidLifeXis


In reply to Re^3: invoking umask command in perl by MidLifeXis
in thread invoking umask command in perl by austin43

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.