Broken PIPE

purewell의 이미지

RedHat 8에서

POSIX Thread와 Socket으로 작업을 하고 있습니다.

STL도 쓰고, unixODBC도 씁니다. ㅡ_-)v

Socket클래스를 만들어서

Socket을 생성한 뒤, Thread로 select합니다.

class CSocket
{
  public:
    int hSocket;
    static void* thrProcess(void* pArgs);

    bool Create(...);
};

bool CSocket::Create(...)
{
  hSocket=socket...
  bind...
  listen...
  pthread_create...
  pthread_detach...
}

void* CSocket::thrProcess(void* pArgs)
{
  select (...);
  for (int fd=0; fd<FD_SETSIZE; fd++)
  {
    if (FD_ISSET(fd, &rfds))
    {
      if (fd==hSocket) _accept();
      else                   _recv(fd);
    }
  }
}

대충 이런 식으로 되어 있는데...

g++ -O2 -g -DDEBUG -D_REENTRANT -lpthread -lodbc source.cpp

ㅡ_-);

컴파일에 이상은 없고, 실행하면 Broken Pipe를 출력하며 죽습니다.

ㅡ_-); gdb 에서 돌리면...

GNU gdb Red Hat Linux (5.2.1-4)
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux"...
(gdb) r
Starting program: /home/purewell/a.out
[New Thread 16384 (LWP 2262)]
Success to connect database
[New Thread 32769 (LWP 2264)]
[New Thread 16386 (LWP 2265)]
Success to initialize socket
Server Start

Program received signal SIGPIPE, Broken pipe.
[Switching to Thread 16386 (LWP 2265)]
0x40025d68 in send () from /lib/i686/libpthread.so.0
(gdb)

ㅡ_-); 왜 그런 것인지... 뭐땀시 문젠지... 알려줘요~

purewell의 이미지

흠... 해결했습니다.

저 소스에는 나오지 않았지만,

서버로 쓴 소켓에 send를 했습니다.

SIGPIPE가 발생한 것이며,

reader가 없는 FD에 write할 때 발생하는 신호라더군요.

_____________________________
언제나 맑고픈 샘이가...
http://purewell.biz

liongo의 이미지

아웅 저것은?

쿠쿠 저것은 그리 문제 삼지 않으셔도 됩니다..

윗분에서 말씀 하신대로.. 닫힌 소켓에다가 write 를 하는 경우입니다..

프로그램 내에서.. 닫힌소켓에다가는 write하는 경우를 처리하셔도

되구요 오에스에 따라서 무시되는경향도 있습니다.. 제가 알기론..

그리고 무시하시려면 SIGPIPE 시그널을 무시하시면 되구요 이경우엔

무시를 하셔도 gdb에서는 시그파이프에서 break됩니다. 물론

continue 하시면 프로그램이 다시돌아가시는것을 확인하실수잇습니다.

gdb에서 break안되게 하시려면 write할때 닫힌소켓에는 write하지

않으시면 됩니다~

' 형식이 내용을 규정한다. '

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.