지금 짜고 있는 프로그램에서 현재 실행 파일이 실행 된 위치를 알고 싶습니다. 워킹디렉토리는 이미 변경 된 후에 구해야 하는 것이라서 getcwd() 이외의 방법을 알고 싶은데 예를들어, ./a.out 파일이 실행 된 위치를 알 수 있는 방법은 없을까요?
ps 명령으로 확인이 될지 모르겠습니다. f옵션을 넣으면 확인가능할것 같습니다.
ps -eLf |grep "a.out"
PID를 알 수 있으면, readlink call을 이용해서 /proc/PID_NUMBER/cwd 를 읽으면 되기는 합니다.
텍스트 포맷에 대한 자세한 정보
<code>
<blockcode>
<apache>
<applescript>
<autoconf>
<awk>
<bash>
<c>
<cpp>
<css>
<diff>
<drupal5>
<drupal6>
<gdb>
<html>
<html5>
<java>
<javascript>
<ldif>
<lua>
<make>
<mysql>
<perl>
<perl6>
<php>
<pgsql>
<proftpd>
<python>
<reg>
<spec>
<ruby>
<foo>
[foo]
ps 명령으로 확인
ps 명령으로 확인이 될지 모르겠습니다.
f옵션을 넣으면 확인가능할것 같습니다.
ps -eLf |grep "a.out"
PID를 알 수 있으면, readlink call을
PID를 알 수 있으면, readlink call을 이용해서 /proc/PID_NUMBER/cwd 를 읽으면 되기는 합니다.
댓글 달기