From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 598 invoked by alias); 25 Feb 2012 05:58:20 -0000 Received: (qmail 588 invoked by uid 22791); 25 Feb 2012 05:58:18 -0000 X-SWARE-Spam-Status: No, hits=-1.4 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 25 Feb 2012 05:58:05 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1S1Adw-0003dL-32 from Yao_Qi@mentor.com ; Fri, 24 Feb 2012 21:58:04 -0800 Received: from SVR-ORW-FEM-03.mgc.mentorg.com ([147.34.97.39]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Fri, 24 Feb 2012 21:57:56 -0800 Received: from [127.0.0.1] (147.34.91.1) by svr-orw-fem-03.mgc.mentorg.com (147.34.97.39) with Microsoft SMTP Server id 14.1.289.1; Fri, 24 Feb 2012 21:58:03 -0800 Message-ID: <4F487823.5030006@codesourcery.com> Date: Sat, 25 Feb 2012 06:24:00 -0000 From: Yao Qi User-Agent: Mozilla/5.0 (X11; Linux i686; rv:10.0) Gecko/20120130 Thunderbird/10.0 MIME-Version: 1.0 To: Pedro Alves CC: Subject: Re: [PATCH] PR server/9684: gdbserver, attach to stopped processes References: <20120224222127.14659.51317.stgit@hit-nxdomain.opendns.com> In-Reply-To: <20120224222127.14659.51317.stgit@hit-nxdomain.opendns.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-02/txt/msg00601.txt.bz2 On 02/25/2012 06:21 AM, Pedro Alves wrote: > +/* Detect `T (stopped)' in `/proc/PID/status'. > + Other states including `T (tracing stop)' are reported as false. */ > + > +static int > +pid_is_stopped (pid_t pid) > +{ > + FILE *status_file; > + char buf[100]; > + int retval = 0; > + > + snprintf (buf, sizeof (buf), "/proc/%d/status", (int) pid); > + status_file = fopen (buf, "r"); > + if (status_file != NULL) > + { > + int have_state = 0; > + > + while (fgets (buf, sizeof (buf), status_file)) > + { > + if (strncmp (buf, "State:", 6) == 0) > + { > + have_state = 1; > + break; > + } > + } > + if (have_state && strstr (buf, "T (stopped)") != NULL) > + retval = 1; > + fclose (status_file); > + } > + return retval; > +} This function is exactly the same as linux-nat.c:pid_is_stopped, so why don't we move them to common/linux-linuxprocfs.c? -- Yao (齐尧)