Is there a way to get the standard error/output path from within the process?
I tried NSTask's standardError
but it returns NSFileHandle, and I need the path as string.
Thank you!
p.s. StandardErrorPath is set in a .plist used by launchd to start the process on system start. The process is a bundle, written in objective c.
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:
StandardErrorPath
, get the file descriptor.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.