Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- 꺠짐
- 인화여고
- ubuntu
- 칼국수
- 출력
- whatis
- IPv6
- core file
- 노트북 정보
- 노트북 배터리 교체
- ubuntu22.04
- xshell4
- vi
- 인천
- 다수 클라이언트
- linux
- 옛날 탕수육
- gdb tip
- spacse
- host key
- 괌
- hostkeyalgorithms
- 괌여행
- 리눅스
- Listen
- C
- vcore
- 디버깅
- kdumo
- thread pid
Archives
- Today
- Total
목록thread pid (1)
극히 개인적이고 극히 대단하지 않은

Multithread program을 작성하고 버그를 잡다보면 thread의 pid를 알아야 간지러운 곳이 해결되는 경우가 있다. 특히 gdb를 이용해서 디버깅을 하는 경우에 아쉬울 때가 많다. 그런 경우에는 thread 내부에서 다음과 같은 코드를 수행하면 자신 thread의 pid를 알 수 있다. syscall(__NR_gettid) 예를 들어 다음과 같이 코딩을 하면 thread 이름과 pid를 확보할 수 있다. #include #include #include void *sample_thread (void *arg) { ... printf ("Thread Information :: [%s][%d]\n", __func__, syscall(__NR_gettid)); ... pthread_exit (NU..
20년차 개발자
2022. 10. 27. 21:05