SIGTERM 문제 .. 도와주십시오...

doogie의 이미지

main thread와 두 개의 thread를 가진 서버 프로그램을
짜는 중인데요..
실행도중에 자꾸 원인모를 SIGTERM을 받아서 죽습니다...

gdb를 걸어봤는데.. 전부 SIGTERM을 받더군요 ㅜㅜ
gdb 메세지는 다음과 같습니다....

Quote:

Program received signal SIGTERM, Terminated.
[Switching to Thread 182903016896 (LWP 28771)]
0x00000037b598e9c5 in __nanosleep_nocancel () from /lib64/tls/libc.so.6

서버의 메인 루프에서 주어진 데이터가 없으면 계속 무한 루프를 돌도록 되어 있습니다.
근데 루프의 usleep(10) 코드에서 자꾸만 죽습니다...
signal handler에서도 특별한 메세지가 없습니다.
errno도 0, SUCCESS이구요...
도움을 절실히 부탁드립니다...

참고로 signal 처리 소스를 올립니다...
signal handler 부분

	fprintf (stderr, "[%d] Signaled [%d], Error : [%d],[%d],[%s]\n",
		info->si_pid, signo, info->si_code, info->si_errno, strerror (info->si_errno));
	exit (EXIT_SUCCESS);

signal setting 부분

	sigset_t set;
	struct sigaction act;

	sigfillset (&set);
	sigprocmask (SIG_SETMASK, &set, NULL);
	memset (&act, 0x00, sizeof(act));
	sigfillset (&act.sa_mask);

	act.sa_handler = SIG_IGN;
	sigaction (SIGPIPE, &act, NULL);
	sigaction (SIGHUP , &act, NULL);
	sigaction (SIGINT , &act, NULL);
	sigaction (SIGQUIT, &act, NULL);

	act.sa_flags = 	SA_SIGINFO;

	act.sa_sigaction = SigTerm;
	sigaction (SIGTERM, &act, NULL);
	sigaction (SIGBUS , &act, NULL);
	sigaction (SIGFPE , &act, NULL);
	sigaction (SIGILL , &act, NULL);
	sigaction (SIGSEGV, &act, NULL);
	sigaction (SIGSYS , &act, NULL);
	sigaction (SIGXCPU, &act, NULL);
	sigaction (SIGXFSZ, &act, NULL);

	sigemptyset (&set);
	sigprocmask (SIG_SETMASK, &set, NULL);
[/code]
sunyzero의 이미지

쓰레드를 사용하신다면 시그널 처리를 바꾸셔야 합니다. 위의 시그널 처리는 싱글 쓰레드 기반 시그널 처리하는 방식입니다. 쓰레드에서는 각 쓰레드의 시그널 매스크를 설정해주시고 작업해주셔야 합니다.

위의 sigprocmask()만 하더라도 MT 환경에서는 안전한 함수가 아닙니다.

그리고 usleep 에서 이상을 일으키는 것은 아마도 SIGALRM 과 관련이 있을듯 합니다.

========================================
* The truth will set you free.

익명 사용자의 이미지

답변 정말 감사합니다...
시그널 처리쪽을 다시 한번 살펴봐야겠네요 ㅜㅜ

그리고 SIGALRM은 현재 전혀 처리를 안하고 있는데요...
무시를 한다거나 하는 처리를 해줘야 하나요?

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.