File: Solaris.hs

package info (click to toggle)
haskell-executable-path 0.0.3-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 88 kB
  • sloc: haskell: 421; makefile: 2
file content (51 lines) | stat: -rw-r--r-- 938 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51


{-
symbolic links to the executable:

Linux:
/proc/<pid>/exe

Solaris: (Solaris 10 only???)
/proc/<pid>/object/a.out (filename only)
/proc/<pid>/path/a.out (complete pathname)

*BSD:
/proc/<pid>/file
-}

{-# LANGUAGE ForeignFunctionInterface #-}

module System.Environment.Executable.Solaris
  ( getExecutablePath  
  , getPID
  )
  where

import Data.Bits
import Data.Word
import Data.Int

import Control.Monad

import Foreign
import Foreign.C

import System.Posix
--import System.FilePath

--------------------------------------------------------------------------------

getPID :: IO Int
getPID = liftM fromIntegral $ getProcessID

getExecutablePath :: IO FilePath
getExecutablePath = do
  pid <- getPID
  fname <- readSymbolicLink $ "/proc/" ++ show pid ++ "/path/a.out"
  --let (path,exename) = splitFileName fname
  --return path
  return fname

--------------------------------------------------------------------------------