Your code should work. You are probably missing some header.
current is a per-cpu variable defined in linux/arch/x86/include/asm/current.h (all the code is for the case of x86):
DECLARE_PER_CPU(struct task_struct *, current_task); static __always_inline struct task_struct *get_current(void) { return percpu_read_stable(current_task); } #define current get_current()
current points to the task running on a CPU at a given moment. Its type is struct task_struct and it is defined in linux/include/linux/sched.h:
struct task_struct { ... pid_t pid; // process identifier pid_t tgid; // process thread group id ... };
You can browse the code for these files in the Linux Cross Reference: