Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6194805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:21:31+00:00 2026-05-24T03:21:31+00:00

I need to investigate/test the behavior of some code on Linux under conditions where

  • 0

I need to investigate/test the behavior of some code on Linux under conditions where close might be interrupted by signal handlers (either with or without SA_RESTART). What is the most convenient setup to make the close syscall sleep for a measurable window of time during which I could try to hit the process with a signal? Some ideas:

  • Intentionally slow/non-responsive NFS mount
  • Custom FUSE driver

But since these are a bit of a pain to setup, I’m wondering if there’s anything more off-the-shelf I could use that could give the desired behavior.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T03:21:32+00:00Added an answer on May 24, 2026 at 3:21 am

    If nobody else has a better idea…

    You could implement your own character device driver. Start with the template from Chapter 3 in Linux Device Drivers (3rd edition), and tweak it to do nothing except block for a while on close(). (You can use msleep or msleep_interruptible from Chapter 7 to do the blocking.)

    Actually, if nobody else suggests something else, I can probably whip this up pretty quickly by adapting some existing code I have. How soon do you need it?

    [edit]

    OK, try this…

    Makefile:

    ifneq ($(KERNELRELEASE),)
            obj-m := closer.o
    
    else
            KERNELDIR ?= /lib/modules/$(shell uname -r)/build
            PWD := $(shell pwd)
    
    default: modules
    
    %:
            $(MAKE) -C $(KERNELDIR) M=$(PWD) "$@"
    
    .PHONY: default
    endif
    

    closer.c:

    #include <linux/init.h>
    #include <linux/module.h>
    #include <linux/miscdevice.h>
    #include <linux/delay.h>
    #include <linux/fs.h>
    
    MODULE_DESCRIPTION("Block-on-close driver");
    MODULE_AUTHOR("Nemo <nemo@self-evident.org>");
    MODULE_LICENSE("GPL");
    #define VERSION "20110705"
    MODULE_VERSION(VERSION);
    
    #define MY_NAME "closer"
    
    int my_open(struct inode *, struct file *);
    int my_release(struct inode *, struct file *);
    ssize_t my_read(struct file *, char __user *, size_t, loff_t *);
    ssize_t my_write(struct file *, const char __user *, size_t, loff_t *);
    
    static struct file_operations my_fops = {
        .owner = THIS_MODULE,
        .open = my_open,
        .read = my_read,
        .write = my_write,
        .release = my_release,
    };
    
    static struct miscdevice my_dev;
    
    int __init
    my_init(void)
    {
        int err = 0;
    
        printk(KERN_INFO "%s: loading version %s\n", MY_NAME, VERSION);
    
        my_dev.minor = MISC_DYNAMIC_MINOR;
        my_dev.name = MY_NAME;
        my_dev.fops = &my_fops;
        err = misc_register(&my_dev);
    
        if (err)
            printk(KERN_ERR "%s: misc_register failed, error %d\n", MY_NAME, err);
    
        return err;
    }
    
    int
    my_open(struct inode *inode, struct file *filp)
    {
        return 0;
    }
    
    ssize_t
    my_read(struct file *file, char __user *p, size_t n, loff_t *off) {
        return 0;
    }
    
    ssize_t
    my_write(struct file *file, const char __user *p, size_t n, loff_t *off) {
        return n;
    }
    
    int
    my_release(struct inode *inode, struct file *filp)
    {
        int err = 0;
        /* 10 second sleep, interruptible. */
        if (msleep_interruptible(10 * 1000) > 0)
            err = -EINTR;
    
        return err;
    }
    
    void __exit
    my_exit(void)
    {
        misc_deregister(&my_dev);
        printk(KERN_INFO "%s: unloaded\n", MY_NAME);
    }
    
    module_init(my_init);
    module_exit(my_exit);
    

    Load the module using “insmod closer.o”. If you have a reasonably modern/complete Linux environment, udev will wake up and generate /dev/closer automatically. If not, you can create the device node yourself:

    mknod /dev/closer c `tr : ' ' </sys/class/misc/closer/dev`
    

    (That is, /sys/class/misc/closer/dev indicates the major:minor to use.)

    Reads and writes work like /dev/null; i.e., EOF on any read, success on any write.

    I have verified that “cat < /dev/closer” blocks in close() for 10 seconds. I have not created a test to catch SIGINT (or whatever) and verify that it actually results in EINTR.

    Built against a 2.6.32 kernel. Let me know how it works for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using reflection, I need to investigate a user DLL and create an object of
Need to an expression that returns only things with an I followed by either
need ask you about some help. I have web app running in Net 2.0.
Need some help about with Memcache. I have created a class and want to
Need to insert selected text on the page into textarea. There must be some
Need to call a filter function on some options based on a radio selected
I have absolutely no knowledge of google docs but i need to investigate something:
Imagine such situation. You get some legacy code or get some new framework. You
I'm writing some tests for a CMS, and I need to know if a
I need to let all projects in solution contain some additional build actions, e.g.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.