{-# LINE 1 "src/System/Proc/Bindings/C.hsc" #-}
{-# LANGUAGE CApiFFI #-}
{-# LANGUAGE CPP #-}
-- {-# OPTIONS_GHC -fplugin Debug.Breakpoint #-}



module System.Proc.Bindings.C
  ( Proc (..)
  , SignalMask
  , Address
  , callocProc
  , freeProc
  , peekProc
  , readNextProcPtr
  , readAllProcsSimple
  , readAllProcsPids
  , readAllProcsUids
  , readSelfProc
  )
where

-- import Debug.Breakpoint
import Foreign
import Foreign.C.Types
import GHC.Stack
import System.Posix.Types
import System.Proc.Bindings.C.Utils
import System.Proc.Bindings.Tab.C

{- | The reason we type alias this is because the procps library will use a different
type to represent addresses depending on the system and some other C macro stuff.

Specifically:

@
if defined(k64test) || (defined(_ABIN32) && _MIPS_SIM == _ABIN32)
type Address = 'CULLong'
else
type Address = 'CULong'
endif
@
-}

{-# LINE 46 "src/System/Proc/Bindings/C.hsc" #-}
type Address = CULong

{-# LINE 48 "src/System/Proc/Bindings/C.hsc" #-}

{- | The reason we type alias this is because the @procps@ library will use a different
type to represent signal masks depending on whether the @SIGNAL_STRING@ macro is defined.

Specifically:

@
ifdef SIGNAL_STRING
type SignalMask = Maybe String
else
type SignalMask = 'CLLong'
endif
@
-}

{-# LINE 63 "src/System/Proc/Bindings/C.hsc" #-}
type SignalMask = Maybe String

{-# LINE 67 "src/System/Proc/Bindings/C.hsc" #-}

{- | All the information we've read about a single process.

This is the "escape hatch" from all the funky C stuff, memory management, bracketed access etc:
'Proc' is just a normal Haskell datatype without any pointers going on, so you can
do what you want with it.

The fields of 'Proc' come from @proc_t@, and are parsed from various files
in the @\/proc\/#\/@ directory.

For more detailed information, see the following man pages:

- [proc_pid_statm.5](https://man7.org/linux/man-pages/man5/proc_pid_statm.5.html)
- [proc_pid_status.5](https://man7.org/linux/man-pages/man5/proc_pid_status.5.html)
- [proc_pid_ns.5](https://man7.org/linux/man-pages/man5/proc_pid_ns.5.html)
- [proc_pid_stat.5](https://man7.org/linux/man-pages/man5/proc_pid_stat.5.html)
- [proc_pid_environ.5](https://man7.org/linux/man-pages/man5/proc_pid_environ.5.html)
- [proc_pid_cmdline.5](https://man7.org/linux/man-pages/man5/proc_pid_cmdline.5.html)
- [proc_pid_cgroup.5](https://man7.org/linux/man-pages/man5/proc_pid_cgroup.5.html)
- [proc_pid_task.5](https://man7.org/linux/man-pages/man5/proc_pid_task.5.html)
-}
data Proc = Proc
  { Proc -> CInt
taskId :: CInt 
  {- ^ Task ID, the POSIX thread ID (see also: 'threadGroupId').

  Always read.
  -}
  , Proc -> CInt
parentPid :: CInt 
  {- ^ Process ID of parent process.

  Read when 'System.Proc.Bindings.Tab.Config.flagStat' or
  'System.Proc.Bindings.Tab.Config.flagStatus'.
  -}
  , Proc -> CULong
majDelta :: CULong 
  {- ^ Major page faults since last update.

  Read when 'System.Proc.Bindings.Tab.Config.flagStat' (special).
  -}
  , Proc -> CULong
minDelta :: CULong 
  {- ^ Minor page faults since last update.

  Read when 'System.Proc.Bindings.Tab.Config.flagStat' (special).
  -}
  , Proc -> CUInt
cpuUsagePercent :: CUInt 
  {- ^ %CPU usage (is not filled in by 'System.Proc.Bindings.readNextProc').

  Read when 'System.Proc.Bindings.Tab.Config.flagStat' (special).
  -}
  , Proc -> CChar
processStateCode :: CChar 
  {- ^ Single-char code for process state.

  Read when 'System.Proc.Bindings.Tab.Config.flagStat' or
  'System.Proc.Bindings.Tab.Config.flagStatus'.

  From [proc_pid_stat](https://man7.org/linux/man-pages/man5/proc_pid_stat.5.html):

  @
  R      Running

  S      Sleeping in an interruptible wait

  D      Waiting in uninterruptible disk sleep

  Z      Zombie

  T      Stopped (on a signal) or (before Linux 2.6.33) trace stopped

  t      Tracing stop (Linux 2.6.33 onward)

  W      Paging (only before Linux 2.6.0)

  X      Dead (from Linux 2.6.0 onward)

  x      Dead (Linux 2.6.33 to 3.13 only)

  K      Wakekill (Linux 2.6.33 to 3.13 only)

  W      Waking (Linux 2.6.33 to 3.13 only)

  P      Parked (Linux 3.9 to 3.13 only)

  I      Idle (Linux 4.14 onward)
  @
  -}
  -- , procc_pad_1 :: CChar 
  -- , procc_pad_2 :: CChar 
  -- , procc_pad_3 :: CChar 
  , Proc -> CULLong
userModeCPUTime :: CULLong 
  {- ^ User-mode CPU time accumulated by process.

  Read when 'System.Proc.Bindings.Tab.Config.flagStat'.
  -}
  , Proc -> CULLong
kernelModeCPUTime :: CULLong 
  {- ^ Kernel-mode CPU time accumulated by process.

  Read when 'System.Proc.Bindings.Tab.Config.flagStat'.
  -}
  , Proc -> CULLong
cumulativeUserModeCPUTime :: CULLong 
  {- ^ Cumulative utime of process and reaped children.

  Read when 'System.Proc.Bindings.Tab.Config.flagStat'.
  -}
  , Proc -> CULLong
cumulativeKernelModeCPUTime :: CULLong 
  {- ^ Cumulative stime of process and reaped children.

  Read when 'System.Proc.Bindings.Tab.Config.flagStat'.
  -}
  , Proc -> CULLong
startTimeInSeconds :: CULLong 
  {- ^ Start time of process: seconds since system boot.

  Read when 'System.Proc.Bindings.Tab.Config.flagStat'.
  -}
  , Proc -> SignalMask
pendingSignalMask :: SignalMask
  {- ^ Mask of pending signals, per-task for readtask() but per-proc for readproc().

  Read when 'System.Proc.Bindings.Tab.Config.fillStatus'.
  -}
  , Proc -> SignalMask
blockSignalMask :: SignalMask
  {- ^ Mask of blocked signals.

  Read when 'System.Proc.Bindings.Tab.Config.fillStatus'.
  -}
  , Proc -> SignalMask
ignoredSignalMask :: SignalMask
  {- ^ Mask of ignored signals.

  Read when 'System.Proc.Bindings.Tab.Config.fillStatus'.
  -}
  , Proc -> SignalMask
caughtSignalMask :: SignalMask
  {- ^ Mask of caught signals.

  Read when 'System.Proc.Bindings.Tab.Config.fillStatus'.
  -}
  , Proc -> SignalMask
perTaskPendingSignals :: SignalMask
  {- ^ Mask of per task pending signals.

  Read when 'System.Proc.Bindings.Tab.Config.fillStatus'.
  -}
  , Proc -> CULong
codeStartAddress :: Address 
  {- ^ Address of beginning of code segment.

  Read when 'System.Proc.Bindings.Tab.Config.flagStat'.
  -}
  , Proc -> CULong
codeEndAddress :: Address 
  {- ^ Address of end of code segment.

  Read when 'System.Proc.Bindings.Tab.Config.flagStat'.
  -}
  , Proc -> CULong
stackBottomAddress :: Address 
  {- ^ Address of the bottom of stack for the process.

  Read when 'System.Proc.Bindings.Tab.Config.flagStat'.
  -}
  , Proc -> CULong
kernelStackPointer :: Address 
  {- ^ Kernel stack pointer.

  Read when 'System.Proc.Bindings.Tab.Config.flagStat'.
  -}
  , Proc -> CULong
kernelInstructionPointer :: Address 
  {- ^ Kernel instruction pointer.

  Read when 'System.Proc.Bindings.Tab.Config.flagStat'.
  -}
  , Proc -> CULong
kernelWaitChannelAddress :: Address 
  {- ^ Address of kernel wait channel proc is sleeping in.

  Read when 'System.Proc.Bindings.Tab.Config.flagStat' (special).
  -}
  , Proc -> CLong
kernelSchedulingPriority :: CLong 
  {- ^ Kernel scheduling priority.

  Read when 'System.Proc.Bindings.Tab.Config.flagStat'.
  -}
  , Proc -> CLong
niceLevel :: CLong 
  {- ^ Standard unix nice level of process.

  Read when 'System.Proc.Bindings.Tab.Config.flagStat'.
  -}
  , Proc -> CLong
rss :: CLong 
  {- ^ Identical to 'residentNonSwappedMemInPages'.

  Read when 'System.Proc.Bindings.Tab.Config.flagStat'.
  -}
  , Proc -> CLong
alarm :: CLong 
  {- ^ Not used since Linux 2.6.17.

  Read when 'System.Proc.Bindings.Tab.Config.flagStat'.

  From [proc_pid_stat](https://man7.org/linux/man-pages/man5/proc_pid_stat.5.html):

  @
  The time in jiffies before the next SIGALRM is sent
  to the process due to an interval timer.  Since
  Linux 2.6.17, this field is no longer maintained,
  and is hard coded as 0.
  @
  -}
  , Proc -> CLong
totalVirtualMemInPages :: CLong 
  {- ^ Total virtual memory (as # pages).

  Read when 'System.Proc.Bindings.Tab.Config.flagMem'.
  -}
  , Proc -> CLong
residentNonSwappedMemInPages :: CLong 
  {- ^ Resident non-swapped memory (as # pages).

  Read when 'System.Proc.Bindings.Tab.Config.flagMem'.
  -}
  , Proc -> CLong
sharedMemInPages :: CLong 
  {- ^ Shared (mmap'd) memory (as # pages).

  Read when 'System.Proc.Bindings.Tab.Config.flagMem'.
  -}
  , Proc -> CLong
textResidentSetInPages :: CLong 
  {- ^ Text (exe) resident set (as # pages).

  Read when 'System.Proc.Bindings.Tab.Config.flagMem'.
  -}
  , Proc -> CLong
libraryResidentSetInPages :: CLong 
  {- ^ Library resident set (always 0 w/ 2.6).

  Read when 'System.Proc.Bindings.Tab.Config.flagMem'.
  -}
  , Proc -> CLong
dataAndStackResidentSetInPages :: CLong 
  {- ^ Data+stack resident set (as # pages).

  Read when 'System.Proc.Bindings.Tab.Config.flagMem'.
  -}
  , Proc -> CLong
dirtyPages :: CLong 
  {- ^ Dirty pages (always 0 w/ 2.6).

  Read when 'System.Proc.Bindings.Tab.Config.flagMem'.
  -}
  , Proc -> CULong
vmSizeInKb :: CULong 
  {- ^ Equals 'totalVirtualMemInPages' (as kb).

  Read when 'System.Proc.Bindings.Tab.Config.fillStatus'.
  -}
  , Proc -> CULong
vmLockedPagesInKb :: CULong 
  {- ^ Locked pages (as kb).

  Read when 'System.Proc.Bindings.Tab.Config.fillStatus'.
  -}
  , Proc -> CULong
vmRssInKb :: CULong 
  {- ^ Equals 'rss' and/or 'residentNonSwappedMemInPages' (as kb).

  Read when 'System.Proc.Bindings.Tab.Config.fillStatus'.
  -}
  , Proc -> CULong
vmRssAnonInKb :: CULong 
  {- ^ The @anonymous@ portion of vm_rss (as kb).

  Read when 'System.Proc.Bindings.Tab.Config.fillStatus'.
  -}
  , Proc -> CULong
vmRssFileBackedInKb :: CULong 
  {- ^ The @file-backed@ portion of vm_rss (as kb).

  Read when 'System.Proc.Bindings.Tab.Config.fillStatus'.
  -}
  , Proc -> CULong
vmRssSharedInKb :: CULong 
  {- ^ The @shared@ portion of vm_rss (as kb).

  Read when 'System.Proc.Bindings.Tab.Config.fillStatus'.
  -}
  , Proc -> CULong
vmDataSizeInKb :: CULong 
  {- ^ Data only size (as kb).

  Read when 'System.Proc.Bindings.Tab.Config.fillStatus'.
  -}
  , Proc -> CULong
vmStackSizeInKb :: CULong 
  {- ^ Stack only size (as kb).

  Read when 'System.Proc.Bindings.Tab.Config.fillStatus'.
  -}
  , Proc -> CULong
vmSwapSizeInKb :: CULong 
  {- ^ Based on linux-2.6.34 "swap ents" (as kb).

  Read when 'System.Proc.Bindings.Tab.Config.fillStatus'.
  -}
  , Proc -> CULong
vmExeInKb :: CULong 
  {- ^ Equals 'textResidentSetInPages' (as kb).

  Read when 'System.Proc.Bindings.Tab.Config.fillStatus'.
  -}
  , Proc -> CULong
vmTotalLibraryPagesInKb :: CULong 
  {- ^ Total, not just used, library pages (as kb).

  Read when 'System.Proc.Bindings.Tab.Config.fillStatus'.
  -}
  , Proc -> CULong
realTimePriority :: CULong 
  {- ^ Real-time priority.

  Read when 'System.Proc.Bindings.Tab.Config.flagStat'.
  -}
  , Proc -> CULong
schedulingClass :: CULong 
  {- ^ Scheduling class.

  Read when 'System.Proc.Bindings.Tab.Config.flagStat'.
  -}
  , Proc -> CULong
virtualMemoryInPages :: CULong 
  {- ^ Number of pages of virtual memory.

  Read when 'System.Proc.Bindings.Tab.Config.flagStat'.
  -}
  , Proc -> CULong
residentSetSizeLimit :: CULong 
  {- ^ Resident set size limit?

  Read when 'System.Proc.Bindings.Tab.Config.flagStat'.
  -}
  , Proc -> CULong
kernelFlags :: CULong 
  {- ^ Kernel flags for the process.

  Read when 'System.Proc.Bindings.Tab.Config.flagStat'.
  -}
  , Proc -> CULong
minorPageFaults :: CULong 
  {- ^ Number of minor page faults since process start.

  Read when 'System.Proc.Bindings.Tab.Config.flagStat'.
  -}
  , Proc -> CULong
majorPageFaults :: CULong 
  {- ^ Number of major page faults since process start.

  Read when 'System.Proc.Bindings.Tab.Config.flagStat'.
  -}
  , Proc -> CULong
cumulativeMinorPageFaults :: CULong 
  {- ^ Cumulative min_flt of process and child processes.

  Read when 'System.Proc.Bindings.Tab.Config.flagStat'.
  -}
  , Proc -> CULong
cumulativeMajorPageFaults :: CULong 
  {- ^ Cumulative maj_flt of process and child processes.

  Read when 'System.Proc.Bindings.Tab.Config.flagStat'.
  -}
  , Proc -> [String]
environment :: [String]
  {- ^ Environment string vector (/proc/#/environ).

  Read when 'System.Proc.Bindings.Tab.Config.flagEnviron'.
  -}
  , Proc -> [String]
cmdline :: [String]
  {- ^ Command line string vector (/proc/#/cmdline).

  Read when 'System.Proc.Bindings.Tab.Config.fillCom'
  or 'System.Proc.Bindings.Tab.Config.fillArg'.
  -}
  , Proc -> [String]
cgroup :: [String]
  {- ^ Cgroup string vector (/proc/#/cgroup).

  Read when 'System.Proc.Bindings.Tab.Config.flagCGroup'.
  -}
  , Proc -> SignalMask
cgroupName :: Maybe String
  {- ^ Name portion of above (if possible).

  Read when 'System.Proc.Bindings.Tab.Config.flagCGroup'
  and not 'System.Proc.Bindings.Tab.Config.editCGroupAsSingleVector'.
  -}
  , Proc -> SignalMask
supplementaryGids :: Maybe String
  {- ^ Supplementary gids as comma delimited str.

  Read when 'System.Proc.Bindings.Tab.Config.fillStatus'.
  -}
  , Proc -> SignalMask
supplementaryGroupNames :: Maybe String
  -- ^ Supp grp names as comma delimited str, derived from supgid.
  , Proc -> SignalMask
effectiveUserName :: Maybe String
  {- ^ Effective user name.

  Read when 'System.Proc.Bindings.Tab.Config.flagStat' or
  'System.Proc.Bindings.Tab.Config.flagStatus'.
  -}
  , Proc -> SignalMask
realUserName :: Maybe String
  {- ^ Real user name.

  Read when 'System.Proc.Bindings.Tab.Config.fillStatus'.
  -}
  , Proc -> SignalMask
savedUserName :: Maybe String
  {- ^ Saved user name.

  Read when 'System.Proc.Bindings.Tab.Config.fillStatus'.
  -}
  , Proc -> SignalMask
filesystemUserName :: Maybe String
  {- ^ Filesystem user name.

  Read when 'System.Proc.Bindings.Tab.Config.fillStatus'.
  -}
  , Proc -> SignalMask
realGroupName :: Maybe String
  {- ^ Real group name.

  Read when 'System.Proc.Bindings.Tab.Config.fillStatus'.
  -}
  , Proc -> SignalMask
effectiveGroupname :: Maybe String
  {- ^ Effective group name.

  Read when 'System.Proc.Bindings.Tab.Config.fillStatus'.
  -}
  , Proc -> SignalMask
savedGroupName :: Maybe String
  {- ^ Saved group name.

  Read when 'System.Proc.Bindings.Tab.Config.fillStatus'.
  -}
  , Proc -> SignalMask
filesystemGroupName :: Maybe String
  {- ^ Filesystem group name.

  Read when 'System.Proc.Bindings.Tab.Config.fillStatus'.
  -}
  , Proc -> SignalMask
cmd :: Maybe String
  {- ^ Basename of executable file in call to exec(2).

  Read when 'System.Proc.Bindings.Tab.Config.flagStat' or
  'System.Proc.Bindings.Tab.Config.flagStatus'.
  -}
  -- , procc_ring :: () -- struct proc_t *
  -- , procc_next :: () -- struct proc_t *
  , Proc -> CInt
processGroupId :: CInt 
  {- ^ Process group ID.

  Read when 'System.Proc.Bindings.Tab.Config.flagStat'.
  -}
  , Proc -> CInt
sessionId :: CInt 
  {- ^ Session ID.

  Read when 'System.Proc.Bindings.Tab.Config.flagStat'.
  -}
  , Proc -> CInt
numberOfThreasds :: CInt 
  {- ^ Number of threads, or 0 if no clue.

  Read when 'System.Proc.Bindings.Tab.Config.flagStat' or
  'System.Proc.Bindings.Tab.Config.flagStatus'.
  -}
  , Proc -> CInt
threadGroupId :: CInt 
  {- ^ Thread group ID, the POSIX PID (see also: 'taskId').

  Always read.
  -}
  , Proc -> CInt
ttyNumber :: CInt 
  {- ^ Full device number of controlling terminal.

  Read when 'System.Proc.Bindings.Tab.Config.flagStat'.
  -}
  , Proc -> CInt
effectiveUserId :: CInt 
  {- ^ Effective user ID.

  Read when 'System.Proc.Bindings.Tab.Config.flagStat' or
  'System.Proc.Bindings.Tab.Config.flagStatus'.
  -}
  , Proc -> CInt
effectiveGroupId :: CInt 
  {- ^ Effective group ID.

  Read when 'System.Proc.Bindings.Tab.Config.flagStat' or
  'System.Proc.Bindings.Tab.Config.flagStatus'.
  -}
  , Proc -> CInt
realUserId :: CInt 
  {- ^ Real user ID.

  Read when 'System.Proc.Bindings.Tab.Config.fillStatus'.
  -}
  , Proc -> CInt
realGroupId :: CInt 
  {- ^ Real group ID.

  Read when 'System.Proc.Bindings.Tab.Config.fillStatus'.
  -}
  , Proc -> CInt
savedUserId :: CInt 
  {- ^ Saved user ID.

  Read when 'System.Proc.Bindings.Tab.Config.fillStatus'.
  -}
  , Proc -> CInt
savedGroupId :: CInt 
  {- ^ Saved group ID.

  Read when 'System.Proc.Bindings.Tab.Config.fillStatus'.
  -}
  , Proc -> CInt
filesystemUserId :: CInt 
  {- ^ Fs user ID (used for file access only).

  Read when 'System.Proc.Bindings.Tab.Config.fillStatus'.
  -}
  , Proc -> CInt
filesystemGroupId :: CInt 
  {- ^ Fs group ID (used for file access only).

  Read when 'System.Proc.Bindings.Tab.Config.fillStatus'.
  -}
  , Proc -> CInt
terminalProcessGroupId :: CInt 
  {- ^ Terminal process group ID.

  Read when 'System.Proc.Bindings.Tab.Config.flagStat'.
  -}
  , Proc -> CInt
exitSignal :: CInt 
  {- ^ Might not be SIGCHLD.

  Read when 'System.Proc.Bindings.Tab.Config.flagStat'.
  -}
  , Proc -> CInt
cpu :: CInt 
  {- ^ Current (or most recent?) CPU.

  Read when 'System.Proc.Bindings.Tab.Config.flagStat'.
  -}
  , Proc -> CInt
oomScore :: CInt 
  {- ^ (badness for OOM killer).

  Read when 'System.Proc.Bindings.Tab.Config.flagOOM'.
  -}
  , Proc -> CInt
oomAdjustment :: CInt 
  {- ^ (adjustment to OOM score).

  Read when 'System.Proc.Bindings.Tab.Config.flagOOM'.
  -}
  , Proc -> [CLong]
namespaces :: [CLong]
  {- ^ Inode number of namespaces.

  Read when 'System.Proc.Bindings.Tab.Config.flagNS'.
  -}
  , Proc -> SignalMask
systemdContainerName :: Maybe String
  -- ^ Systemd vm/container name.
  , Proc -> SignalMask
systemdSessionOwnerUid :: Maybe String
  -- ^ Systemd session owner uid.
  , Proc -> SignalMask
systemdLoginSessionSeat :: Maybe String
  -- ^ Systemd login session seat.
  , Proc -> SignalMask
systemdLoginSessionId :: Maybe String
  -- ^ Systemd login session ID.
  , Proc -> SignalMask
systemdSliceUnit :: Maybe String
  -- ^ Systemd slice unit.
  , Proc -> SignalMask
systemdSystemUnitId :: Maybe String
  -- ^ Systemd system unit ID.
  , Proc -> SignalMask
systemdUserUnitId :: Maybe String
  -- ^ Systemd user unit ID.
  , Proc -> SignalMask
lxcContainerName :: Maybe String
  -- ^ Lxc container name.
  }
  deriving (Int -> Proc -> ShowS
[Proc] -> ShowS
Proc -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Proc] -> ShowS
$cshowList :: [Proc] -> ShowS
show :: Proc -> String
$cshow :: Proc -> String
showsPrec :: Int -> Proc -> ShowS
$cshowsPrec :: Int -> Proc -> ShowS
Show, Proc -> Proc -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Proc -> Proc -> Bool
$c/= :: Proc -> Proc -> Bool
== :: Proc -> Proc -> Bool
$c== :: Proc -> Proc -> Bool
Eq)

readLongList :: Ptr CLong -> IO [CLong]
readLongList :: Ptr CLong -> IO [CLong]
readLongList = forall a.
(HasCallStack, Storable a, Num a, Eq a) =>
Ptr a -> IO [a]
readNullTermArray
{-# INLINE readLongList #-}

peekProc :: HasCallStack => Ptr Proc -> IO Proc
peekProc :: HasCallStack => Ptr Proc -> IO Proc
peekProc Ptr Proc
ptr = do
  HasCallStack => String -> IO ()
xprintf forall a b. (a -> b) -> a -> b
$ String
"peekProc " forall a. Semigroup a => a -> a -> a
<> forall a. Show a => a -> String
show Ptr Proc
ptr
  CInt
taskId <- ((\Ptr Proc
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr Proc
hsc_ptr Int
0)) Ptr Proc
ptr
{-# LINE 601 "src/System/Proc/Bindings/C.hsc" #-}
  parentPid <- ((\hsc_ptr -> peekByteOff hsc_ptr 4)) ptr
{-# LINE 602 "src/System/Proc/Bindings/C.hsc" #-}
  majDelta <- ((\hsc_ptr -> peekByteOff hsc_ptr 8)) ptr
{-# LINE 603 "src/System/Proc/Bindings/C.hsc" #-}
  minDelta <- ((\hsc_ptr -> peekByteOff hsc_ptr 16)) ptr
{-# LINE 604 "src/System/Proc/Bindings/C.hsc" #-}
  cpuUsagePercent <- ((\hsc_ptr -> peekByteOff hsc_ptr 24)) ptr
{-# LINE 605 "src/System/Proc/Bindings/C.hsc" #-}
  processStateCode <- ((\hsc_ptr -> peekByteOff hsc_ptr 28)) ptr
{-# LINE 606 "src/System/Proc/Bindings/C.hsc" #-}
  -- procc_pad_1 <- (#peek proc_t, pad_1) ptr
  -- procc_pad_2 <- (#peek proc_t, pad_2) ptr
  -- procc_pad_3 <- (#peek proc_t, pad_3) ptr
  CULLong
userModeCPUTime <- ((\Ptr Proc
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr Proc
hsc_ptr Int
32)) Ptr Proc
ptr
{-# LINE 610 "src/System/Proc/Bindings/C.hsc" #-}
  kernelModeCPUTime <- ((\hsc_ptr -> peekByteOff hsc_ptr 40)) ptr
{-# LINE 611 "src/System/Proc/Bindings/C.hsc" #-}
  cumulativeUserModeCPUTime <- ((\hsc_ptr -> peekByteOff hsc_ptr 48)) ptr
{-# LINE 612 "src/System/Proc/Bindings/C.hsc" #-}
  cumulativeKernelModeCPUTime <- ((\hsc_ptr -> peekByteOff hsc_ptr 56)) ptr
{-# LINE 613 "src/System/Proc/Bindings/C.hsc" #-}
  startTimeInSeconds <- ((\hsc_ptr -> peekByteOff hsc_ptr 64)) ptr
{-# LINE 614 "src/System/Proc/Bindings/C.hsc" #-}

{-# LINE 615 "src/System/Proc/Bindings/C.hsc" #-}
  pendingSignalMask <- (readStringMaybe $ ((\hsc_ptr -> hsc_ptr `plusPtr` 72)) ptr)
{-# LINE 616 "src/System/Proc/Bindings/C.hsc" #-}
  blockSignalMask <- (readStringMaybe $ ((\hsc_ptr -> hsc_ptr `plusPtr` 90)) ptr)
{-# LINE 617 "src/System/Proc/Bindings/C.hsc" #-}
  ignoredSignalMask <- (readStringMaybe $ ((\hsc_ptr -> hsc_ptr `plusPtr` 108)) ptr)
{-# LINE 618 "src/System/Proc/Bindings/C.hsc" #-}
  caughtSignalMask <- (readStringMaybe $ ((\hsc_ptr -> hsc_ptr `plusPtr` 126)) ptr)
{-# LINE 619 "src/System/Proc/Bindings/C.hsc" #-}
  perTaskPendingSignals <- (readStringMaybe $ ((\hsc_ptr -> hsc_ptr `plusPtr` 144)) ptr)
{-# LINE 620 "src/System/Proc/Bindings/C.hsc" #-}

{-# LINE 627 "src/System/Proc/Bindings/C.hsc" #-}
  CULong
codeStartAddress <- ((\Ptr Proc
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr Proc
hsc_ptr Int
168)) Ptr Proc
ptr
{-# LINE 628 "src/System/Proc/Bindings/C.hsc" #-}
  codeEndAddress <- ((\hsc_ptr -> peekByteOff hsc_ptr 176)) ptr
{-# LINE 629 "src/System/Proc/Bindings/C.hsc" #-}
  stackBottomAddress <- ((\hsc_ptr -> peekByteOff hsc_ptr 184)) ptr
{-# LINE 630 "src/System/Proc/Bindings/C.hsc" #-}
  kernelStackPointer <- ((\hsc_ptr -> peekByteOff hsc_ptr 192)) ptr
{-# LINE 631 "src/System/Proc/Bindings/C.hsc" #-}
  kernelInstructionPointer <- ((\hsc_ptr -> peekByteOff hsc_ptr 200)) ptr
{-# LINE 632 "src/System/Proc/Bindings/C.hsc" #-}
  kernelWaitChannelAddress <- ((\hsc_ptr -> peekByteOff hsc_ptr 208)) ptr
{-# LINE 633 "src/System/Proc/Bindings/C.hsc" #-}
  kernelSchedulingPriority <- ((\hsc_ptr -> peekByteOff hsc_ptr 216)) ptr
{-# LINE 634 "src/System/Proc/Bindings/C.hsc" #-}
  niceLevel <- ((\hsc_ptr -> peekByteOff hsc_ptr 224)) ptr
{-# LINE 635 "src/System/Proc/Bindings/C.hsc" #-}
  rss <- ((\hsc_ptr -> peekByteOff hsc_ptr 232)) ptr
{-# LINE 636 "src/System/Proc/Bindings/C.hsc" #-}
  alarm <- ((\hsc_ptr -> peekByteOff hsc_ptr 240)) ptr
{-# LINE 637 "src/System/Proc/Bindings/C.hsc" #-}
  totalVirtualMemInPages <- ((\hsc_ptr -> peekByteOff hsc_ptr 248)) ptr
{-# LINE 638 "src/System/Proc/Bindings/C.hsc" #-}
  residentNonSwappedMemInPages <- ((\hsc_ptr -> peekByteOff hsc_ptr 256)) ptr
{-# LINE 639 "src/System/Proc/Bindings/C.hsc" #-}
  sharedMemInPages <- ((\hsc_ptr -> peekByteOff hsc_ptr 264)) ptr
{-# LINE 640 "src/System/Proc/Bindings/C.hsc" #-}
  textResidentSetInPages <- ((\hsc_ptr -> peekByteOff hsc_ptr 272)) ptr
{-# LINE 641 "src/System/Proc/Bindings/C.hsc" #-}
  libraryResidentSetInPages <- ((\hsc_ptr -> peekByteOff hsc_ptr 280)) ptr
{-# LINE 642 "src/System/Proc/Bindings/C.hsc" #-}
  dataAndStackResidentSetInPages <- ((\hsc_ptr -> peekByteOff hsc_ptr 288)) ptr
{-# LINE 643 "src/System/Proc/Bindings/C.hsc" #-}
  dirtyPages <- ((\hsc_ptr -> peekByteOff hsc_ptr 296)) ptr
{-# LINE 644 "src/System/Proc/Bindings/C.hsc" #-}
  vmSizeInKb <- ((\hsc_ptr -> peekByteOff hsc_ptr 304)) ptr
{-# LINE 645 "src/System/Proc/Bindings/C.hsc" #-}
  vmLockedPagesInKb <- ((\hsc_ptr -> peekByteOff hsc_ptr 312)) ptr
{-# LINE 646 "src/System/Proc/Bindings/C.hsc" #-}
  vmRssInKb <- ((\hsc_ptr -> peekByteOff hsc_ptr 320)) ptr
{-# LINE 647 "src/System/Proc/Bindings/C.hsc" #-}
  vmRssAnonInKb <- ((\hsc_ptr -> peekByteOff hsc_ptr 328)) ptr
{-# LINE 648 "src/System/Proc/Bindings/C.hsc" #-}
  vmRssFileBackedInKb <- ((\hsc_ptr -> peekByteOff hsc_ptr 336)) ptr
{-# LINE 649 "src/System/Proc/Bindings/C.hsc" #-}
  vmRssSharedInKb <- ((\hsc_ptr -> peekByteOff hsc_ptr 344)) ptr
{-# LINE 650 "src/System/Proc/Bindings/C.hsc" #-}
  vmDataSizeInKb <- ((\hsc_ptr -> peekByteOff hsc_ptr 352)) ptr
{-# LINE 651 "src/System/Proc/Bindings/C.hsc" #-}
  vmStackSizeInKb <- ((\hsc_ptr -> peekByteOff hsc_ptr 360)) ptr
{-# LINE 652 "src/System/Proc/Bindings/C.hsc" #-}
  vmSwapSizeInKb <- ((\hsc_ptr -> peekByteOff hsc_ptr 368)) ptr
{-# LINE 653 "src/System/Proc/Bindings/C.hsc" #-}
  vmExeInKb <- ((\hsc_ptr -> peekByteOff hsc_ptr 376)) ptr
{-# LINE 654 "src/System/Proc/Bindings/C.hsc" #-}
  vmTotalLibraryPagesInKb <- ((\hsc_ptr -> peekByteOff hsc_ptr 384)) ptr
{-# LINE 655 "src/System/Proc/Bindings/C.hsc" #-}
  realTimePriority <- ((\hsc_ptr -> peekByteOff hsc_ptr 392)) ptr
{-# LINE 656 "src/System/Proc/Bindings/C.hsc" #-}
  schedulingClass <- ((\hsc_ptr -> peekByteOff hsc_ptr 400)) ptr
{-# LINE 657 "src/System/Proc/Bindings/C.hsc" #-}
  virtualMemoryInPages <- ((\hsc_ptr -> peekByteOff hsc_ptr 408)) ptr
{-# LINE 658 "src/System/Proc/Bindings/C.hsc" #-}
  residentSetSizeLimit <- ((\hsc_ptr -> peekByteOff hsc_ptr 416)) ptr
{-# LINE 659 "src/System/Proc/Bindings/C.hsc" #-}
  kernelFlags <- ((\hsc_ptr -> peekByteOff hsc_ptr 424)) ptr
{-# LINE 660 "src/System/Proc/Bindings/C.hsc" #-}
  minorPageFaults <- ((\hsc_ptr -> peekByteOff hsc_ptr 432)) ptr
{-# LINE 661 "src/System/Proc/Bindings/C.hsc" #-}
  majorPageFaults <- ((\hsc_ptr -> peekByteOff hsc_ptr 440)) ptr
{-# LINE 662 "src/System/Proc/Bindings/C.hsc" #-}
  cumulativeMinorPageFaults <- ((\hsc_ptr -> peekByteOff hsc_ptr 448)) ptr
{-# LINE 663 "src/System/Proc/Bindings/C.hsc" #-}
  cumulativeMajorPageFaults <- ((\hsc_ptr -> peekByteOff hsc_ptr 456)) ptr
{-# LINE 664 "src/System/Proc/Bindings/C.hsc" #-}
  environment <- readStringList =<< ((\hsc_ptr -> peekByteOff hsc_ptr 464)) ptr
{-# LINE 665 "src/System/Proc/Bindings/C.hsc" #-}
  cmdline <- readStringList =<< ((\hsc_ptr -> peekByteOff hsc_ptr 472)) ptr
{-# LINE 666 "src/System/Proc/Bindings/C.hsc" #-}
  cgroup <- readStringList =<< ((\hsc_ptr -> peekByteOff hsc_ptr 480)) ptr
{-# LINE 667 "src/System/Proc/Bindings/C.hsc" #-}
  cgroupName <- readStringMaybe =<< ((\hsc_ptr -> peekByteOff hsc_ptr 488)) ptr
{-# LINE 668 "src/System/Proc/Bindings/C.hsc" #-}
  supplementaryGids <- readStringMaybe =<< ((\hsc_ptr -> peekByteOff hsc_ptr 496)) ptr
{-# LINE 669 "src/System/Proc/Bindings/C.hsc" #-}
  supplementaryGroupNames <- readStringMaybe =<< ((\hsc_ptr -> peekByteOff hsc_ptr 504)) ptr
{-# LINE 670 "src/System/Proc/Bindings/C.hsc" #-}
  effectiveUserName <- readStringMaybe (((\hsc_ptr -> hsc_ptr `plusPtr` 512)) ptr)
{-# LINE 671 "src/System/Proc/Bindings/C.hsc" #-}
  realUserName <- readStringMaybe (((\hsc_ptr -> hsc_ptr `plusPtr` 545)) ptr)
{-# LINE 672 "src/System/Proc/Bindings/C.hsc" #-}
  savedUserName <- readStringMaybe (((\hsc_ptr -> hsc_ptr `plusPtr` 578)) ptr)
{-# LINE 673 "src/System/Proc/Bindings/C.hsc" #-}
  filesystemUserName <- readStringMaybe (((\hsc_ptr -> hsc_ptr `plusPtr` 611)) ptr)
{-# LINE 674 "src/System/Proc/Bindings/C.hsc" #-}
  realGroupName <- readStringMaybe (((\hsc_ptr -> hsc_ptr `plusPtr` 644)) ptr)
{-# LINE 675 "src/System/Proc/Bindings/C.hsc" #-}
  effectiveGroupname <- readStringMaybe (((\hsc_ptr -> hsc_ptr `plusPtr` 677)) ptr)
{-# LINE 676 "src/System/Proc/Bindings/C.hsc" #-}
  savedGroupName <- readStringMaybe (((\hsc_ptr -> hsc_ptr `plusPtr` 710)) ptr)
{-# LINE 677 "src/System/Proc/Bindings/C.hsc" #-}
  filesystemGroupName <- readStringMaybe (((\hsc_ptr -> hsc_ptr `plusPtr` 743)) ptr)
{-# LINE 678 "src/System/Proc/Bindings/C.hsc" #-}
  cmd <- readStringMaybe (((\hsc_ptr -> hsc_ptr `plusPtr` 776)) ptr)
{-# LINE 679 "src/System/Proc/Bindings/C.hsc" #-}
  -- procc_ring <- (#peek proc_t, ring) ptr
  -- procc_next <- (#peek proc_t, next) ptr
  CInt
processGroupId <- ((\Ptr Proc
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr Proc
hsc_ptr Int
856)) Ptr Proc
ptr
{-# LINE 682 "src/System/Proc/Bindings/C.hsc" #-}
  sessionId <- ((\hsc_ptr -> peekByteOff hsc_ptr 860)) ptr
{-# LINE 683 "src/System/Proc/Bindings/C.hsc" #-}
  numberOfThreasds <- ((\hsc_ptr -> peekByteOff hsc_ptr 864)) ptr
{-# LINE 684 "src/System/Proc/Bindings/C.hsc" #-}
  threadGroupId <- ((\hsc_ptr -> peekByteOff hsc_ptr 868)) ptr
{-# LINE 685 "src/System/Proc/Bindings/C.hsc" #-}
  ttyNumber <- ((\hsc_ptr -> peekByteOff hsc_ptr 872)) ptr
{-# LINE 686 "src/System/Proc/Bindings/C.hsc" #-}
  effectiveUserId <- ((\hsc_ptr -> peekByteOff hsc_ptr 876)) ptr
{-# LINE 687 "src/System/Proc/Bindings/C.hsc" #-}
  effectiveGroupId <- ((\hsc_ptr -> peekByteOff hsc_ptr 880)) ptr
{-# LINE 688 "src/System/Proc/Bindings/C.hsc" #-}
  realUserId <- ((\hsc_ptr -> peekByteOff hsc_ptr 884)) ptr
{-# LINE 689 "src/System/Proc/Bindings/C.hsc" #-}
  realGroupId <- ((\hsc_ptr -> peekByteOff hsc_ptr 888)) ptr
{-# LINE 690 "src/System/Proc/Bindings/C.hsc" #-}
  savedUserId <- ((\hsc_ptr -> peekByteOff hsc_ptr 892)) ptr
{-# LINE 691 "src/System/Proc/Bindings/C.hsc" #-}
  savedGroupId <- ((\hsc_ptr -> peekByteOff hsc_ptr 896)) ptr
{-# LINE 692 "src/System/Proc/Bindings/C.hsc" #-}
  filesystemUserId <- ((\hsc_ptr -> peekByteOff hsc_ptr 900)) ptr
{-# LINE 693 "src/System/Proc/Bindings/C.hsc" #-}
  filesystemGroupId <- ((\hsc_ptr -> peekByteOff hsc_ptr 904)) ptr
{-# LINE 694 "src/System/Proc/Bindings/C.hsc" #-}
  terminalProcessGroupId <- ((\hsc_ptr -> peekByteOff hsc_ptr 908)) ptr
{-# LINE 695 "src/System/Proc/Bindings/C.hsc" #-}
  exitSignal <- ((\hsc_ptr -> peekByteOff hsc_ptr 912)) ptr
{-# LINE 696 "src/System/Proc/Bindings/C.hsc" #-}
  cpu <- ((\hsc_ptr -> peekByteOff hsc_ptr 916)) ptr
{-# LINE 697 "src/System/Proc/Bindings/C.hsc" #-}
  oomScore <- ((\hsc_ptr -> peekByteOff hsc_ptr 920)) ptr
{-# LINE 698 "src/System/Proc/Bindings/C.hsc" #-}
  oomAdjustment <- ((\hsc_ptr -> peekByteOff hsc_ptr 924)) ptr
{-# LINE 699 "src/System/Proc/Bindings/C.hsc" #-}
  namespaces <- readLongList (((\hsc_ptr -> hsc_ptr `plusPtr` 928)) ptr)
{-# LINE 700 "src/System/Proc/Bindings/C.hsc" #-}
  systemdContainerName <- readStringMaybe =<< ((\hsc_ptr -> peekByteOff hsc_ptr 976)) ptr
{-# LINE 701 "src/System/Proc/Bindings/C.hsc" #-}
  systemdSessionOwnerUid <- readStringMaybe =<< ((\hsc_ptr -> peekByteOff hsc_ptr 984)) ptr
{-# LINE 702 "src/System/Proc/Bindings/C.hsc" #-}
  systemdLoginSessionSeat <- readStringMaybe =<< ((\hsc_ptr -> peekByteOff hsc_ptr 992)) ptr
{-# LINE 703 "src/System/Proc/Bindings/C.hsc" #-}
  systemdLoginSessionId <- readStringMaybe =<< ((\hsc_ptr -> peekByteOff hsc_ptr 1000)) ptr
{-# LINE 704 "src/System/Proc/Bindings/C.hsc" #-}
  systemdSliceUnit <- readStringMaybe =<< ((\hsc_ptr -> peekByteOff hsc_ptr 1008)) ptr
{-# LINE 705 "src/System/Proc/Bindings/C.hsc" #-}
  systemdSystemUnitId <- readStringMaybe =<< ((\hsc_ptr -> peekByteOff hsc_ptr 1016)) ptr
{-# LINE 706 "src/System/Proc/Bindings/C.hsc" #-}
  systemdUserUnitId <- readStringMaybe =<< ((\hsc_ptr -> peekByteOff hsc_ptr 1024)) ptr
{-# LINE 707 "src/System/Proc/Bindings/C.hsc" #-}
  lxcContainerName <- readStringMaybe =<< ((\hsc_ptr -> peekByteOff hsc_ptr 1032)) ptr
{-# LINE 708 "src/System/Proc/Bindings/C.hsc" #-}
  pure Proc {..}

callocProc :: IO (Ptr Proc)
callocProc :: IO (Ptr Proc)
callocProc = forall a. Int -> IO (Ptr a)
callocBytes ((Int
1040))
{-# LINE 712 "src/System/Proc/Bindings/C.hsc" #-}

foreign import capi unsafe "read_proc_wrapper" readNextProcPtr :: Ptr ProcTabC -> Ptr Proc -> IO (Ptr Proc)

foreign import capi unsafe "free_proc_wrapper" freeProc :: Ptr Proc -> IO ()

foreign import capi unsafe "readallprocs_simple" readAllProcsSimple :: CInt -> IO (Ptr (Ptr Proc))

foreign import capi unsafe "readallprocs_pids" readAllProcsPids :: CInt -> Ptr CPid -> IO (Ptr (Ptr Proc))

foreign import capi unsafe "readallprocs_uids" readAllProcsUids :: CInt -> Ptr CUid -> CInt -> IO (Ptr (Ptr Proc))

foreign import capi unsafe "lookup_self_wrapper" readSelfProc :: IO (Ptr Proc)