C12 [C/C++] signal handler library 활용과 소스코드 공유 signal handler library C/C++ 에는 signal.h 를 사용한 signal 함수가 존재한다. 시스템 인터럽트 외 여러 상황에 사용할 수 있기 때문에 필수로 시그널 처리를 하게 된다. 가장 쉬운 예를 들면 ctrl + c를 통해 SIGINT를 발생시켜 프로그램을 종료할 때 메모리 반환을 하여 메모리 누수를 막거나 소켓 또는 IO 핸들러들의 상태를 닫아주어 graceful 한 종료를 해야 할 때 사용된다. 수많은 프로그램을 작성하면서 번번이 signal에 대한 정의와 시그널 처리에 따른 콜백 함수 등을 작성하기 귀찮아 라이브러리로 작성하였고 이를 공유한다. https://github.com/muabow/home/tree/main/library/cpp/lib_signal GitHub - .. 2021. 12. 24. [C/C++] pthread_mutex_lock 설명 pthread_mutex_lock - 뮤텍스 잠금을 얻거나 해제 1. 사용법 #include int pthread_mutex_lock(pthread_mutex_t *mutex); int pthread_mutex_trylock(pthread_mutex_t *mutex); int pthread_mutex_unlock(pthread_mutex_t *mutex); int pthread_mutex_destroy(pthread_mutex_t *mutex); 2. 설명 * mutex - MUTual EXclusion(상호 배제)devide의 줄임말로 쓰레드간 공유하는 데이터 영역을 보호하기 위해서 사용 - 데이터 영역의 보호는 critical section(임계 영역)을 만들고 임계 영역내에 단하나의 쓰레드만이 진입.. 2020. 3. 30. Base64 With OpenSSL C API OpenSSL has the ability to perform Base64 encodings and decodings. There seems to be many queries for working examples on how to use this functionality. Unfortunately, theexample on the OpenSSL site is quite obtuse, and every other example I have come accross does not work. So here is some working code. Enjoy! Get The Code You can download this entire gist here. It consists of the following file.. 2014. 7. 14. 리눅스에서 C 프로그램 개발방법 1.소스작성(확장자 .c) 2.gcc 를 이용한 컴파일 3.실행 컴파일 : 컴퓨터가 이해할 수 있도록 변환하는 과정 #cd /work #pwd #vi hello.c #include int main() { int i; for(i=1;i 컴파일 하기 #ls #file hello.c hello.c: ASCII C program text # #file hello.exe hello.exe: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), not stripped # #./hello.exe (현재 디렉토리에 있는 hello.exe 를 실행하라는 의미) 2009. 1. 13. 이전 1 2 다음