On Tue, 08 Sep 2020 10:24:06 -0400, in gmane.comp.hardware.beagleboard.user Dennis Lee Bieber <dennis.l.bieber-re5jqeeqqe8avxtiumw...@public.gmane.org> wrote:
As a follow-up, using YOUR source, I added one line (and changed the file name) -=-=-=- debian@beaglebone:~/exploring$ cat test.cpp #include<gnu/libc-version.h> #include<sys/syscall.h> #include<sys/types.h> #include<iostream> #include<signal.h> #include <unistd.h> <=================== using namespace std; int main(){ //gnu_get_libc_version() returns a string that identifies the //glibc version available on the system. cout << "The GNU libc version is " << gnu_get_libc_version() << endl; // process id tid is thread identifier // look inside sys/syscall.h for System Call Numbers pid_t tid; //pid_t is of type integer tid = syscall(SYS_gettid); // make a system call to get the process id cout << "The Current PID is: " << tid << endl; //can also get by calling getpid() function from signal.h cout << "The Current PID is: " << getpid() << endl; // Can get current UserID by using: int uid = syscall(SYS_getuid); cout << "It is being run by user with ID: " << uid << endl; // or getting the value from syscalls.kernelgrok.com uid = syscall(0xc7); cout << "It is being run by user with ID: " << uid << endl; return 0; } debian@beaglebone:~/exploring$ -=-=-=- debian@beaglebone:~/exploring$ g++ test.cpp -o test debian@beaglebone:~/exploring$ ./test The GNU libc version is 2.28 The Current PID is: 2396 The Current PID is: 2396 It is being run by user with ID: 1000 It is being run by user with ID: 1000 debian@beaglebone:~/exploring$ The example program in the second edition has that line. -- Dennis L Bieber -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/ue5flflhfmf3ug4tmapm6qa0vonfe5q1gp%404ax.com.