I am using some third party library which is using stderr to print error and it don’t gives any callback for logging.
I am using linux daemon call to create daemon of the process.
Is there a way I can set stderr to file after daemon call ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use the
opensystem call to open the file, then do this:dup2(filefd, 2). That will setstderrto the opened file. You can thenclose(filefd). You can do theopenbefore callingdaemon, but I wouldn’t recommend thedup2and subsequentcloseuntil after callingdaemon.