                                                      p_comm: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
                                                      e_ppid: 0,
                                                      e_pgid: 0,
-                                                     uid: 0)
+                                                        uid: 0)
                 kinfo_for_pid(pid, &kinfoProc)
                 
                 

import Darwin
import Foundation

/// Process information
public struct ProcessInfo {
    let pid     : Int
    let ppid    : Int
    let pgid    : Int
    let uid     : Int
    let command : String
    /// sys/proc.h - SIDL, SRUN, SSLEEP, SSTOP, SZOMB
    var status  : Int
    
    
    public init(pid: Int, ppid: Int, pgid: Int, uid: Int, command: String,
                                                           status: Int) {
        self.pid     = pid
        self.ppid    = ppid
        self.pgid    = pgid
        self.uid     = uid
        self.command = command
        self.status  = status
    }
}

    }
    
    
    public static func arch(pid: pid_t) -> cpu_type_t {
        var arch: cpu_type_t = CPU_TYPE_ANY
        
        // "sysctl.proc_cputype" not documented anywhere. Doesn't even show
        // up when doing sysctl -A. But you can see it if you run sysctl sysctl.
        // Hard coding it does carry a risk, as it could change down the road.
        // Hence, top calls sysctlnametomib() first
        var mib: [Int32] = [0, 103, pid]
        var len: size_t = UInt(sizeof(cpu_type_t))
        
        let result = sysctl(&mib, UInt32(mib.count), &arch, &len, nil, 0)
        
        #if DEBUG
            if result != 0 {
                println("ERROR - \(__FILE__):\(__FUNCTION__):\(__LINE__)")
            }
        #endif
        
        return arch
    }
    
    
    //--------------------------------------------------------------------------
    // MARK: PRIVATE METHODS - HELPERS
    //--------------------------------------------------------------------------
    
    
    /// Based on macro of the same name from sys/time.h
    private static func timeradd(tvp: timeval, uvp: timeval, inout vvp: timeval) {
        vvp.tv_sec  = tvp.tv_sec + uvp.tv_sec
