Added pid plugin

This commit is contained in:
James Booth
2013-09-01 23:51:02 +01:00
parent 4b5c887d51
commit 87ee5ec584
2 changed files with 33 additions and 0 deletions

11
pid/Makefile Normal file
View 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
View 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);
}