From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752476AbdI0XbJ (ORCPT ); Wed, 27 Sep 2017 19:31:09 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:33010 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752337AbdI0XbI (ORCPT ); Wed, 27 Sep 2017 19:31:08 -0400 Date: Wed, 27 Sep 2017 16:31:06 -0700 From: Andrew Morton To: Roman Gushchin Cc: Linus Torvalds , , Alexander Viro , Ingo Molnar , , Subject: Re: [RESEND] proc, coredump: add CoreDumping flag to /proc/pid/status Message-Id: <20170927163106.84b9622f183f087eff7f6da7@linux-foundation.org> In-Reply-To: <20170920230634.31572-1-guro@fb.com> References: <20170914224431.GA9735@castle> <20170920230634.31572-1-guro@fb.com> X-Mailer: Sylpheed 3.4.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 20 Sep 2017 16:06:34 -0700 Roman Gushchin wrote: > Right now there is no convenient way to check if a process is being > coredumped at the moment. > > It might be necessary to recognize such state to prevent killing > the process and getting a broken coredump. > Writing a large core might take significant time, and the process > is unresponsive during it, so it might be killed by timeout, > if another process is monitoring and killing/restarting > hanging tasks. > > To provide an ability to detect if a process is in the state of > being coreduped, we can expose a boolean CoreDumping flag > in /proc/pid/status. > > Example: > $ cat core.sh > #!/bin/sh > > echo "|/usr/bin/sleep 10" > /proc/sys/kernel/core_pattern > sleep 1000 & > PID=$! > > cat /proc/$PID/status | grep CoreDumping > kill -ABRT $PID > sleep 1 > cat /proc/$PID/status | grep CoreDumping > > $ ./core.sh > CoreDumping: 0 > CoreDumping: 1 I assume you have some real-world use case which benefits from this. > fs/proc/array.c | 6 ++++++ > 1 file changed, 6 insertions(+) A Documentation/ would be appropriate? Include a brief mention of *why* someone might want to use this...