From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3699 invoked by alias); 18 May 2009 13:22:07 -0000 Received: (qmail 3687 invoked by uid 22791); 18 May 2009 13:22:05 -0000 X-SWARE-Spam-Status: No, hits=0.7 required=5.0 tests=AWL,BAYES_20,J_CHICKENPOX_44,J_CHICKENPOX_75,SPF_SOFTFAIL X-Spam-Check-By: sourceware.org Received: from smtp02.lnh.mail.rcn.net (HELO smtp02.lnh.mail.rcn.net) (207.172.157.102) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 18 May 2009 13:21:57 +0000 Received: from mr02.lnh.mail.rcn.net ([207.172.157.22]) by smtp02.lnh.mail.rcn.net with ESMTP; 18 May 2009 09:21:55 -0400 Received: from smtp01.lnh.mail.rcn.net (smtp01.lnh.mail.rcn.net [207.172.4.11]) by mr02.lnh.mail.rcn.net (MOS 3.10.5-GA) with ESMTP id PWL71234; Mon, 18 May 2009 09:21:53 -0400 (EDT) Received: from 65-78-31-9.c3-0.lex-ubr3.sbo-lex.ma.cable.rcn.com (HELO homebase.localnet) ([65.78.31.9]) by smtp01.lnh.mail.rcn.net with ESMTP; 18 May 2009 09:21:53 -0400 Received: from psmith by homebase.localnet with local (Exim 4.69) (envelope-from ) id 1M62mu-0000ua-E3; Mon, 18 May 2009 09:21:52 -0400 Subject: Re: Partial cores using Linux "pipe" core_pattern From: Paul Smith Reply-To: psmith@gnu.org To: Paul Pluzhnikov Cc: gdb@sourceware.org In-Reply-To: <8ac60eac0905172304t4deae98bxbd4f0b1d2186a8a0@mail.gmail.com> References: <1242609756.2800.135.camel@homebase.localnet> <8ac60eac0905172304t4deae98bxbd4f0b1d2186a8a0@mail.gmail.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit Date: Mon, 18 May 2009 13:22:00 -0000 Message-Id: <1242652911.2800.160.camel@homebase.localnet> Mime-Version: 1.0 X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2009-05/txt/msg00115.txt.bz2 On Sun, 2009-05-17 at 23:04 -0700, Paul Pluzhnikov wrote: > On Sun, May 17, 2009 at 6:22 PM, Paul Smith wrote: > > > I've instrumented every single function with checking for errors and > > writing issues to syslog (including informational messages so I know the > > logging works) and no errors are printed. The size of the core that I > > get from read(2)'ing stdin is just short, but read(2) never fails or > > shows any errors! > > You can't be read(2)ing stdin, since read(2) doesn't take FILE*. > Are you doing read(0, ...) or are you doing fread(..., stdin) ? > > If the latter, are you handling the feof() vs. ferror() difference > correctly? A small code sample might help. Oh sorry; I should have been explicit. I use fileno(stdin) to get an FD. I'm ONLY using FD-based calls; I don't use FILE*-based calls at all (on stdin). Here's my main loop. I've hacked it a bit for ridiculous safety (for example I used to have the errno log inside the if (l<0) but moved it out of a surfeit of caution). When I get a short core, the syslog entry at the end shows the actual short core length, not the "full" core length--so basically that's all the kernel is giving me. ------------------------------------------------------------ coref = gzopen(core_path, "wb"); if (!coref) { _vlog(LOG_ERR, "gzopen(%s): %s\n", core_path, _zerr()); exit(1); } ssize_t tot = 0; while (true) { errno = 0; ssize_t l = read(infd, buf, bufsize); if (errno) _vlog(LOG_ERR, "read(stdin): %s\n", strerror(errno)); // Did we read it all? if (l == 0) break; if (caughtsig) { _vlog(LOG_ERR, "savecore got signal %d--continuing\n", caughtsig); caughtsig = 0; } // Did we get an error? if (l < 0) { if (errno == EINTR || errno == EAGAIN) continue; _clean_and_fail(); } // Write what we got so far tot += l; char *p = buf; while (l > 0) { int w = gzwrite(coref, p, l); if (w <= 0) { _vlog(LOG_ERR, "gzwrite(%s): %s\n", core_path, _zerr()); _clean_and_fail(); } // Some amount of write succeeded; write the rest p += w; l -= w; } } if (gzclose(coref) < 0) { _vlog(LOG_ERR, "gzclose(%s): %s\n", core_path, _zerr()); _clean_and_fail(); } // Give some information on the core _vlog(LOG_ERR, "%s(%s): coredump complete: core.%s (%lu B)\n", argv[av_CMDNAME], argv[av_PID], core_suffix, tot); -- ------------------------------------------------------------------------------- Paul D. Smith Find some GNU make tips at: http://www.gnu.org http://make.mad-scientist.us "Please remain calm...I may be mad, but I am a professional." --Mad Scientist