Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • This solution would work exactly as the question was asked. However, I'd like to use the solution for mounts/unmounts as well. I have further clarified my question. Commented May 11, 2018 at 18:03
  • 1
    Handling mounts on EXIT is somewhat difficult. What do you do if umount fails because there is an open file handle? We're EXITing, so it has to be immediate. Commented May 11, 2018 at 18:10
  • Agreed. In my case, errors won't happen, since I'm creating tmp dir and mounting newly created device. Arch does something like this with arch-chroot, and it hasn't caused me any issues. See here: gist.github.com/systemdarena/… Commented May 11, 2018 at 18:12