Added pid plugin
This commit is contained in:
11
pid/Makefile
Normal file
11
pid/Makefile
Normal file
@@ -0,0 +1,11 @@
|
||||
all: pid.so
|
||||
|
||||
%.so:%.o
|
||||
$(CC) -shared -fpic -lprofanity -o $@ $^
|
||||
|
||||
%.o:%.c
|
||||
$(CC) $(INCLUDE) -D_GNU_SOURCE -D_BSD_SOURCE -fpic -O3 -std=c99 \
|
||||
-Wall -Wextra -lprofanity -pedantic -c -o $@ $<
|
||||
|
||||
clean:
|
||||
$(RM) pid.so
|
||||
22
pid/pid.c
Normal file
22
pid/pid.c
Normal file
@@ -0,0 +1,22 @@
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <profapi.h>
|
||||
|
||||
void
|
||||
cmd_pid(char **args)
|
||||
{
|
||||
pid_t pid = getpid();
|
||||
pid_t ppid = getppid();
|
||||
char buf[50];
|
||||
sprintf(buf, "PID: %d, parent PID: %d", pid, ppid);
|
||||
prof_cons_show(buf);
|
||||
prof_cons_alert();
|
||||
}
|
||||
|
||||
void
|
||||
prof_init(const char * const version, const char * const status)
|
||||
{
|
||||
prof_register_command("/pid", 0, 0, "/pid", "Get process ID", "Get process ID", cmd_pid);
|
||||
}
|
||||
Reference in New Issue
Block a user