<div dir="ltr">    I wrote and tested the following C++ program after reading the Stack Overflow article ,<br><a href="http://stackoverflow.com/questions/31747247/change-real-process-name-in-c-on-linux">http://stackoverflow.com/questions/31747247/change-real-process-name-in-c-on-linux</a>.<br><br>I discovered my  program could not  programatically change the Ubuntu 16.04 System Monitor <br>process name from cli or mono to an unique name such as "fancy_name". How can we<br>fix my botched C++ program for the use case where multiple Linux processes<br>have an identical name and we would like to kill processes by process name <br>using pgrep? My architect does not wish to use UNIX scripts for this purpose.<br><div><br>#include <unistd.h>   <br>#include <sys/types.h>  <br>#include <sys/wait.h>   <br>#include <iostream><br>#include <fstream><br>#include <cstdlib><br>#include <csignal><br>#include <string.h><br>#include <sys/prctl.h><br><br>using namespace std;<br><br>int main(int argc, char* argvp[])<br>{<br>   char lockfile[4096];<br>   char environment_variable[4096];<br>   char exe[4096];<br><br>   cout << argvp[1] << endl;<br>   if (strcmp(argvp[1] , "-start") == 0)<br>   {<br>        sprintf(exe,"%s.exe",argvp[2]);<br>    cout << exe << endl;<br>        ifstream myReadFile;<br>        myReadFile.open(exe);<br>        if (!myReadFile.good())<br>    {<br>        cout << "-start Unrecognized C# executable " << exe << endl; <br>                return 0;<br>    }<br>    char *argv[] = { "/usr/lib/mono/4.5/mono-service.exe", <br>                         exe,<br>                         0<br>               };<br> <br>    sprintf(environment_variable,"LD_LIBRARY_PATH=%s",argvp[3]);<br>    <br>    cout << environment_variable << endl;<br>        char *envp[] =<br>        {<br>                environment_variable,<br>            0<br>        };<br>    cout << argv[0] << endl;<br>        execle("/usr/lib/mono/4.5/mono-service.exe",<br>               "fancy_name",<br>               exe,<br>               (char *)0,<br>               envp<br>               );<br>        perror("Oops!");<br>    }<br></div><div>    return 1;<br>}<br><br></div><div>Any help is greatly appreciated.<br></div>       Frank</div>