From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757504Ab3ANQzx (ORCPT ); Mon, 14 Jan 2013 11:55:53 -0500 Received: from mailhub.sw.ru ([195.214.232.25]:31106 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757485Ab3ANQzu (ORCPT ); Mon, 14 Jan 2013 11:55:50 -0500 From: Andrey Vagin To: linux-kernel@vger.kernel.org Cc: criu@openvz.org, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, Andrey Vagin , Serge Hallyn , Oleg Nesterov , Andrew Morton , "Eric W. Biederman" , Al Viro , Pavel Emelyanov , Cyrill Gorcunov , Michael Kerrisk Subject: =?UTF-8?q?=5BPATCH=200/3=5D=20signalfd=3A=20a=20kernel=20interface=20for=20dumping/restoring=20pending=20signals=20=28v3=29?= Date: Mon, 14 Jan 2013 20:53:52 +0400 Message-Id: <1358182435-19245-1-git-send-email-avagin@openvz.org> X-Mailer: git-send-email 1.7.11.7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The idea is simple. We need to get the siginfo for each signal on dump, and then return it back on restore. The first problem is that the kernel doesn’t report complete siginfo-s in user-space. In a signal handler the kernel strips SI_CODE from siginfo. When a siginfo is received from signalfd, it has a different format with fixed sizes of fields. The interface of signalfd was extended. If a signalfd is created with the flag SFD_RAW, it returns siginfo in a raw format. rt_sigqueueinfo looks suitable for restoring signals, but it can’t send siginfo with a positive si_code, because these codes are reserved for the kernel. In the real world each person has right to do anything with himself, so I think a process should able to send any siginfo to itself. v2: add ability to dump signals without dequeuing them. pread with non-zero offset is used for this. offset encodes a queue (private of shared) and a sequence number of a signal in the queue. Thanks to Oleg for this idea. v3: minor cleanups Cc: Serge Hallyn Cc: Oleg Nesterov Cc: Andrew Morton Cc: "Eric W. Biederman" Cc: Al Viro Cc: Pavel Emelyanov CC: Cyrill Gorcunov Cc: Michael Kerrisk Andrey Vagin (3): signal: allow to send any siginfo to itself signalfd: add ability to return siginfo in a raw format (v2) signalfd: add ability to read siginfo-s without dequeuing signals (v4) fs/signalfd.c | 109 +++++++++++++++++++++++++++++++++++++++--- include/uapi/linux/signalfd.h | 6 +++ kernel/signal.c | 6 ++- 3 files changed, 113 insertions(+), 8 deletions(-) -- 1.7.11.7