Why Ubuntu 16.04 C++ program cannot programatically stop mono-service?

Frank Chang frankchang91 at gmail.com
Tue May 17 09:31:26 UTC 2016


Hi Karl,
    Thank you for your excellent solution to the pkill problem
where we use the fact that mono-service sets a  process ID
in the lockfile.

    But when I do this, Stopping process message does not
show in tail -f  /var/log/syslog output. Is it possible to fix that?

    Also, when we start in the mono-service mode on Ubuntu Linux 16.04 , we
would like to create
and store a log file at wherever the user wants. I tried this URL,
stackoverflow.com/questions/11024474/capture-mono-service-stdout-console-output

where it says do this:

mono-service2 myservice.exe -l:/var/run/test --debug > log.txt

which does not work when I test the following C++ program:

include <unistd.h>     // execv(), fork()
#include <sys/types.h>  // pid_t
#include <sys/wait.h>   // waitpid()
#include <stdio.h>

int main(int argc, char* argvp)
{
   char *argv[] = { "/usr/lib/mono/4.5/mono-service.exe",
                    "Audio_Video_Recorder.exe", "--debug", ">&",
"./LOGCamster.txt", 0};


    char *envp[] =
    {
        "LD_LIBRARY_PATH=.",
        0
    };
    execve(argv[0], &argv[0], envp);
    fprintf(stderr, "Oops!\n");
    return -1;

}

because I observe no log file being created. How could I fix

this error?


Any help is greatly appreciated.

Thank you.

       Frank
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20160517/2136fe7f/attachment.html>


More information about the ubuntu-users mailing list