NetBSD-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Am I traced?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
I'm trying to write a check whether I am a traced process.
Is the following code correct:
#define _KMEMUSER
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/sysctl.h>
#include <stdio.h>
#include <unistd.h>
#include <kvm.h>
#include <err.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
int traced = -1;
kvm_t *kd;
int cnt;
struct kinfo_proc *info;
size_t size = sizeof(info);
kd = kvm_open(NULL, NULL, NULL, KVM_NO_FILES, "kvm_open");
if (kd == NULL)
err(EXIT_FAILURE, "kvm_open");
info = kvm_getprocs(kd, KERN_PROC_PID, getpid(), &cnt);
if (info == NULL)
err(EXIT_FAILURE, "kvm_getprocs");
traced = info->kp_proc.p_flag & P_TRACED;
kvm_close(kd);
printf("traced=%d\n", traced);
return 0;
}
I'm getting weird results for info->kp_proc.p_flag indicating that I
was timeouted during sleep.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
iQIcBAEBCAAGBQJXDHD0AAoJEEuzCOmwLnZsX1oQALCjHzn3DZpGsBDCBOmbT+bh
Jb6xCf/TYCqQXW3gdkqVhY7AsKR/FObU+Wfw+H2tAjCYCdCUTiIFJYgDXZuxnK8u
bE1ocQjiJz19lVLdW4kHAywntOW+1Wo+LSIXWR2oVp8YVle/xbiHkdmXuCDfu6Zj
wx8VcM9ijOoTC3zsfyywDywtyVYggTvGEMSY2eWF9u1BV6CmUMLNat1rpXEK2/wM
YjVWXJwHZDEYUpupEc5IMf/EIyEk3b/O5mt7b3L1FOYFSAFRedHf2xPPduYAPo0L
KU0iozNRFQDeDXr2rDuHZMyqmzkrSOPLUP3rIRBEOPr4NrnCj5pSDP2Rjo4UUm7Y
nMRE3Oy+POLbYTLcfQCiWiEWANtmP/6ps5pl/qpq+rDuNuElAtcsS1lbSmEaHxQL
mNk0sheLvDPIG8kjqffRFgY8r7I0Y6eNOkumLghHFu206ZMLhG191puzEZA7nHGh
S8XNfRaHRIRr/fW79dTl8fZ867jB/3d6lUVkZeYcy9CTx22emWOAMAdHrXnhcQQD
bH1Rn6yGkbbmQujDWIWGKwbgJP4sPpkWrjj0d8+uoPuhlG8uUEYGXRd/10wfPPYv
FlaNrSqdnnVJfUZJgraPUQvFyxfTDNrKGFLNvl8MFnmX5mtTjYqqKuPXUnXA80P7
aUBU/do74EyXgYUnu8mv
=Ds5E
-----END PGP SIGNATURE-----
Home |
Main Index |
Thread Index |
Old Index