From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 111265 invoked by alias); 18 Oct 2017 14:18:39 -0000 Mailing-List: contact libc-help-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Post: List-Help: , Sender: libc-help-owner@sourceware.org Received: (qmail 111248 invoked by uid 89); 18 Oct 2017 14:18:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=HTo:U*libc-help, H*Ad:U*libc-help, yubin, H*r:10.80.174 X-HELO: mail-wm0-f43.google.com Received: from mail-wm0-f43.google.com (HELO mail-wm0-f43.google.com) (74.125.82.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 18 Oct 2017 14:18:38 +0000 Received: by mail-wm0-f43.google.com with SMTP id t69so10412237wmt.2 for ; Wed, 18 Oct 2017 07:18:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=6kwL2FyNI2uC+dUPrlIaQiH7F6Xo8EpyiAdwOdkFZoQ=; b=SrBanKfSC9DqhCYF2L/Q6Cup5aH5dTK68PNnMyvCqoJTsVe4TxqzMFgdsm2RE9rLxd nFbtRj2hAF/CdMbrOuoFw24cEXsOn7cBEGb8XnvDAXGaFvS2lYntL0q72stMELvg/FMJ EgNN9V4K9GDJ0/n2RSsRoeoBSW2ef7LTMZuEIomch0Rb13UMOWu79VsNCtuk+uXhZIFO KCciJz+Zhfz2Zm9Ha2BCJ8EtkHbMx+jOXC5IZRVaotzVzdm8GaFvI7AlmYLzu0sPYHU4 pw6COb3mQjzZsZ8+TOjtA11j+C2SKI+cvbVfeGUGa7WveRi8pSRBtEGhlbRfPc1LXUXb e/NQ== X-Gm-Message-State: AMCzsaWDomggQwlxyKgTTItJmpCgCIM2f/7cA/K3C2GNsp9uqCOy7v5F S7UJLiGRD3Tx3Pv9mmypMQujpPA5muTcxLXXAx63 X-Google-Smtp-Source: ABhQp+QpF5z8C6/6IqfATFpoAIgr/o3dSyrOq6WRYwIGDxRo1UR0HQYjsa/Zo1s3Om6HdhESmFDCbk0fwBkNUs4yt/4= X-Received: by 10.80.215.198 with SMTP id m6mr335343edj.63.1508336315764; Wed, 18 Oct 2017 07:18:35 -0700 (PDT) MIME-Version: 1.0 Received: by 10.80.174.36 with HTTP; Wed, 18 Oct 2017 07:18:35 -0700 (PDT) From: Yubin Ruan Date: Wed, 18 Oct 2017 14:18:00 -0000 Message-ID: Subject: determine whether code is running in a signal handler context To: libc-help@sourceware.org Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2017-10/txt/msg00013.txt.bz2 Hi, I am writing to see if this is any util functions in libc that can help to determine it is currently running in a signal. I wrote some library and provide a function which will be used in many client code. However this function is not async-signal safe (it calls malloc(3)) so when it is called, I want to detect whether it is currently running in a signal handler. If it is, I can avoid calling those not-async-signal-safe functions which might cause deadlock. that is, I want a `in_signal_handler_context()' utility that can be used as this: int mylibfunc( void ) { if( in_signal_handler_context() ) { return(-1) } // rest of function goes here return( 0 ); } Yubin