Find the answer to your Linux question:
Results 1 to 3 of 3
To create a daemon, you need to execute these 2 lines (among others): Code: init log umask 0 What do each of these do? I didn't find anything on the ...
  1. #1
    Just Joined!
    Join Date
    Dec 2010
    Posts
    15

    [BASH] Daemon template

    To create a daemon, you need to execute these 2 lines (among others):
    Code:
    init log
    umask 0
    What do each of these do?

    I didn't find anything on the 1st line. (The queries returned mostly "the log of the init (process)".)

    Google cast some light on the 2nd line:
    By setting the umask to 0, we will have full access to the files generated by the daemon. Even if you aren't planning on using any files, it is a good idea to set the umask here anyway, just in case you will be accessing files on the filesystem.
    In what case you wouldn't have the same full access?
    Last edited by courteous; 01-07-2011 at 06:23 PM.

  2. #2
    Linux Newbie tetsujin's Avatar
    Join Date
    Oct 2008
    Posts
    115
    Quote Originally Posted by courteous View Post
    To create a daemon, you need to execute these 2 lines (among others):
    Code:
    init log
    umask 0
    What do each of these do?

    I didn't find anything on the 1st line. (The queries returned mostly "the log of the init (process)".)

    Google cast some light on the 2nd line:In what case you wouldn't have the same full access?
    I don't know about the "init log" line. But specifically what umask does is it controls the default permissions of files you create:

    Code:
    $ umask 0
    $ gcc -o test test.c
    $ ls -l test
    -rwxrwxrwx 1 tetsujin tetsujin 6824 Jan  7 18:35 test
    $ # We don't normally want that. Any other user on the system can modify that file!
    $ rm test; umask 022; gcc -o test test.c
    $ ls -l test
    -rwxr-xr-x 1 tetsujin tetsujin 6824 Jan  7 18:37 test
    $ # Note that the write bit, which has value "2" is masked out of the permissions for "group" and "other"
    It's usually worth at least masking out the write bits for "other" (the last "2") and it's often worth masking out the write bit for the "group" (the second-to-last "2").

    Really, I can't think of why you'd want all users on the system to be able to write to your log file...

  3. #3
    Just Joined!
    Join Date
    Dec 2010
    Posts
    15

    init log: anybody knows?

    Quote Originally Posted by tetsujin View Post
    Really, I can't think of why you'd want all users on the system to be able to write to your log file...
    Me neither, this was among the instructions for writing a daemon.
    Quote Originally Posted by tetsujin View Post
    I don't know about the "init log" line.
    Does anybody know? This init log surely can't have been meant as initlog ... why would you need that for a custom daemon?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...