It would be a lot nicer if there was one standard way to do this :-( Rick
On Sat, Jan 5, 2019 at 7:25 AM Enrico Sorichetti via Oorexx-devel < oorexx-devel@lists.sourceforge.net> wrote: > here are three snippets that show how to do it > > APPLE > > #include <stdio.h> > #include <string.h> > #include <stdlib.h> > #include <unistd.h> > > #include <libproc.h> > > > int main() > { > pid_t pid; > > char path[1024]; > > int RC; > char *cp; > > pid = getpid(); > RC = proc_pidpath (pid, path, sizeof(path)); > if ( RC <= 0 ) > { > exit(-1); > } > else > { > cp = strrchr(path,'/'); > *cp=0; > printf("path '%s'\n",path ) ; > exit(0); > } > exit(-1); > } > > Freebsd > /* FreeBSD > */ > #include <stdio.h> > #include <unistd.h> > > int main() > { > char path[1024]; > int size; > > size = readlink( "/proc/curproc/file", path, sizeof(path)-1); > > path[size] = '\0'; > > printf("***** '%s'\n", path ); > > return(0); > } > > linux > > #include <stdio.h> > #include <unistd.h> > > int main() > { > char path[1024]; > int size; > > size = readlink( "/proc/self/exe", path, sizeof(path)-1); > > path[size] = '\0'; > > printf("***** '%s'\n", path ); > > return(0); > } > > enrico > > > On 5 Jan 2019, at 13:07, Rick McGuire <object.r...@gmail.com> wrote: > > My understanding on unix systems is that it is not possible determine the > location of the binary. Please correct me if I'm wrong on this point, but > David Ashley was quite insistent that it was not possible > > > _______________________________________________ > Oorexx-devel mailing list > Oorexx-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/oorexx-devel >
_______________________________________________ Oorexx-devel mailing list Oorexx-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/oorexx-devel