No you can't. Well strictly speaking you can, using a lot of hackery with the OS, but you shouldn't. You shouldn't determine the path for the standard streams and open the path and write/read on it.
Standard input / output/ error are not something associated to files. They are intrinsically associated to file handles, which are not necessarily associated to a path on the file system. They are an intentional abstraction over the concept of paths, so that a program can always write to the standard input/output/error without caring about the actual paths. This way, the choice of the path is done on the side of the user of the program, not the program itself.
What launchd
does when it sees StandardErrorPath
is conceptually this:
- As part of the initialization procedure, it opens the path in
StandardErrorPath
, get the file descriptor.
- Launch the app, setting that file descriptor to the "standard error file descriptor" of the app.
The app, when it wants to write to the standard error, should just write to the standard error,
not try to determine the file path for the standard error and write to it.