how can I know the process's state?

Can I get the process’s state by using its pid?just like the “pidin”,which function I should use?

pidin -p pid
where pid is your pid number

or maybe waitpid()
in C code.

Get the source to spin. In there you will find how to get pretty much any information about a process. Or you can get Neutrino Cook Book ;-)