分类: LINUX
2009-11-05 17:39:23
|
xiaosuo@gentux test $ gcc t_threadname.c -l pthread xiaosuo@gentux test $ ./a.out xx |
xiaosuo@gentux test $ ps aux | grep a.out xiaosuo 29882 0.0 0.0 14144 544 pts/6 Sl+ 16:23 0:00 ./a.out |
xiaosuo@gentux test $ cd /proc/29882/task/ xiaosuo@gentux task $ ls 29882 29883 xiaosuo@gentux task $ cd 29883/ xiaosuo@gentux 29883 $ cat cmdline ./a.outxiaosuo@gentux 29883 $ |
xiaosuo@gentux 29883 $ ps -L -p 29882 PID LWP TTY TIME CMD 29882 29882 pts/6 00:00:00 a.out 29882 29883 pts/6 00:00:00 xx |
xiaosuo@gentux 29883 $ cat stat 29883 (xx) S 7168 29882 7168 34822 29882 4202560 11 0 0 0 2 0 0 0 20 0 2 0 28515372 14483456 136 18446744073709551615 4194304 4196620 140735304261728 18446744073709551615 140435890519585 0 0 0 0 18446744071564503939 0 0 -1 1 0 0 0 0 0 xiaosuo@gentux 29883 $ cat status Name: xx State: S (sleeping) Tgid: 29882 Pid: 29883 PPid: 7168 TracerPid: 0 Uid: 1000 1000 1000 1000 Gid: 1000 1000 1000 1000 FDSize: 256 Groups: 10 18 1000 1001 1005 VmPeak: 14144 kB VmSize: 14144 kB VmLck: 0 kB VmHWM: 548 kB VmRSS: 544 kB VmData: 8388 kB VmStk: 84 kB VmExe: 4 kB VmLib: 1528 kB VmPTE: 32 kB Threads: 2 SigQ: 1/40960 SigPnd: 0000000000000000 ShdPnd: 0000000000000000 SigBlk: 0000000000000000 SigIgn: 0000000000000000 SigCgt: 0000000180000000 CapInh: 0000000000000000 CapPrm: 0000000000000000 CapEff: 0000000000000000 CapBnd: fffffffffffffeff voluntary_ctxt_switches: 4447 nonvoluntary_ctxt_switches: 0 |
chinaunix网友2010-04-02 10:02:30
試著編譯您上面的程式碼,發現必定要帶 -l pthread 請問是何原因呢?不是已經include pthread.h了,為何還需要-l pthread 多謝解惑。