title: Why I have to sudo a command from daemon process?
body: <p>I have a problem about <code>sudo</code>.</p>
  
  <p>I call an Erlang script <em>from a daemon process</em>. (This daemon process is defined by xinetd, and this process will execute an bash script in it. I wrote my Erlang script command into the bash script). The Erlang script is like:</p>
  
  <pre><code>#! /usr/bin/env escript
  main(_) -&gt;
      ok.
  </code></pre>
  
  <p>The script is quite simple and it is ok when I execute it under the shell command line.</p>
  
  <p>But when I call it from the <em>daemon process</em>, it failed with return code of non-zero. I really have no idea.</p>
  
  <p>When I try <code>sudo /path/to/my/erlang_script</code>, it turns alright!!</p>
  
  <p>I am the <code>root</code> myself. Why I have to add <code>sudo</code>? </p>
  
  <p>My xinetd conf is like: (as you can see 'user' is setup to be 'root')</p>
  
  <pre><code>service gtpgwagent
  {
          type            = UNLISTED
          flags           = REUSE
          disable         = no
          socket_type     = stream
          protocol        = tcp
          wait            = no
          user            = root
          instances       = UNLIMITED
          server          = /lab/subsysserv/sbin/in.gtpgwagent
          server_args     = gtpgw
          log_type        = FILE /tmp/ggsnagent_logfile
          log_on_success  += DURATION USERID HOST EXIT
          log_on_failure  += USERID HOST
          env             = /usr/bin:/bin
          port            = 1761
  }
  </code></pre>