You can, current->pid exists and is a process that has been interrupted (there may be an idle thread or any).
If you write inside the Linux scheduler, you have to be very careful. current changed by the scheduler because it chooses a new process to start, so its value depends on when exactly you read it.
source share