I am launching a process through /etc/rc.local and don't expect to be able to write to stdout / stderr because it is daemonized and even if it would work, it would be interleaved with other output making it difficult at best.
That said, my utility is just a shell script, nothing fancy and I can check to see if stdout / stderr are closed, but they appear to be open. So, for curiosity's sake, I attempted to write, but I clearly can see they're closed:
The code I'm using to check if they're closed:
I use either 1 or 2 to check for stdout and stderr.
Now, the reason I care is that I am trying to generalize my code such that it works if it is called through an rc script or interactively. I could tell the script to not write to stdout / stderr, but thought that it would be nice if I could check if they were open / closed to be dynamic.
I think one caveat with this is that this won't work for fd 2 since it is being used here. So, this would only work for fd1 then, right?
That said, my utility is just a shell script, nothing fancy and I can check to see if stdout / stderr are closed, but they appear to be open. So, for curiosity's sake, I attempted to write, but I clearly can see they're closed:
Code:
printf: write error on stdout
The code I'm using to check if they're closed:
Code:
(: >&1) 2>/dev/null
I use either 1 or 2 to check for stdout and stderr.
Now, the reason I care is that I am trying to generalize my code such that it works if it is called through an rc script or interactively. I could tell the script to not write to stdout / stderr, but thought that it would be nice if I could check if they were open / closed to be dynamic.
I think one caveat with this is that this won't work for fd 2 since it is being used here. So, this would only work for fd1 then, right?