// SetPgrp sets the foreground process group ID associated with the // terminal to pgid. See tcsetpgrp(3). func SetPgrp(fd int, pgid int) error { r, err := C.mytcsetpgrp(C.int(fd), C.pid_t(pgid)) if r < 0 { return err } return nil }
func Tcsetpgrp(fd int, pid int) error { i := C.f(C.int(fd), C.pid_t(pid)) if i != 0 { return syscall.Errno(C.e()) } return nil }
func Getpidcon(pid int) (string, error) { var pcon C.security_context_t var scon string rc, err := C.getpidcon(C.pid_t(pid), &pcon) if rc >= 0 { scon = C.GoString(pcon) C.freecon(pcon) err = nil } return scon, err }
func (s *PerProcessStat) CollectAttributes(pid C.int) { // some cgo follows var kp C.struct_kinfo_proc C.get_process_info(&kp, C.pid_t(pid)) s.comm = C.GoString((*C.char)(unsafe.Pointer(&kp.kp_proc.p_comm))) s.Uid = int(kp.kp_eproc.e_ucred.cr_uid) u, err := user.LookupId(fmt.Sprintf("%v", s.Uid)) if err == nil { s.user = u.Username } }
func (ct *Container) Load(p *ProcessDesc, pid int) error { h := C.libct_container_load(ct.ct, C.pid_t(pid)) if C.libct_handle_is_err(unsafe.Pointer(h)) != 0 { p.closeDescriptors(p.closeAfterStart) p.closeDescriptors(p.closeAfterWait) return LibctError{int(C.libct_handle_to_err(unsafe.Pointer(h)))} } p.handle = h return nil }
// sched_setattr(2) func SetAttr(pid int, attr SchedAttr) error { cAttr := C.struct_sched_attr{ C.__u32(C.SCHED_ATTR_SIZE), C.__u32(attr.Policy), C.__u64(attr.Flags), C.__s32(attr.Nice), C.__u32(attr.Priority), C.__u64(attr.Runtime.Nanoseconds()), C.__u64(attr.Deadline.Nanoseconds()), C.__u64(attr.Period.Nanoseconds()), } _, err := C.sched_setattr(C.pid_t(pid), &cAttr, C.uint(0)) return err }
// sched_getattr(2) func GetAttr(pid int) (SchedAttr, error) { attr := SchedAttr{} cAttr := C.struct_sched_attr{} _, err := C.sched_getattr(C.pid_t(pid), &cAttr, C.uint(C.SCHED_ATTR_SIZE), C.uint(0)) if err == nil { attr.Policy = SchedPolicy(cAttr.sched_policy) attr.Flags = SchedFlag(cAttr.sched_flags) attr.Nice = int32(cAttr.sched_nice) // not sure why we need this tail underscore: sched_priority_ attr.Priority = uint32(cAttr.sched_priority_) attr.Runtime = time.Duration(cAttr.sched_runtime) attr.Deadline = time.Duration(cAttr.sched_deadline) attr.Period = time.Duration(cAttr.sched_period) } return attr, err }