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

  • SEARCH
  • Home
  • 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 8148455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:38:58+00:00 2026-06-06T14:38:58+00:00

In Ruby, a call to Process.setsid fails with Operation not permitted error if it’s

  • 0

In Ruby, a call to Process.setsid fails with “Operation not permitted” error if it’s run as non-superuser. Try:

$ irb
irb(main):001:0> Process.setsid
Errno::EPERM: Operation not permitted
    from (irb):1:in `setsid'
    from (irb):1
    from ~/.rbenv/versions/1.9.2-p290/bin/irb:12:in `<main>'

Or, it fails with the same error if I change the uid or the process using Process.uid= method. It works fine if I run the Ruby program as root, and I do not change the UID of the process during runtime.

However, in Ubuntu’s or some other distro’s shell, the setsid (reference: http://linux.die.net/man/2/setsid ) program does not require superuser privileges.

I understand that stdsid resets the program’s session, which is also useful when daemonizing a process. In my code, I’m attempting to change the UID as well as daemonize it, while also resetting the session.

Hence, I’m curious why Process.setsid requires the said privileges, while the setsid program on most UNIX like OSes does not.

  • 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-06-06T14:38:58+00:00Added an answer on June 6, 2026 at 2:38 pm

    Process.setsid is a thin wrap around POSIX setsid(2) whose man page says:

    Errors

    EPERM

    The process group ID of any process equals the PID of the calling
    process. Thus, in particular, setsid() fails if the calling process is
    already a process group leader.

    When your program runs, it’s already a group leader. When deamonizing, you’re expected to fork a new process for your daemon. Process.setsid works without EPERM error after you fork:

    $ irb
    irb> Process.setsid
    Errno::EPERM: Operation not permitted
        from (irb):1:in `setsid'
        from (irb):1
        from /Users/dbenhur/.rbenv/versions/1.9.3-p194/bin/irb:12:in `<main>'
    irb> fork { Process.setsid }
    => 3359
    

    Take a look at Rexec or unicorn for examples of POSIX daemonization in Ruby.

    The setsid(1) program doesn’t get an EPERM error because it forks before calling setsid(2). See line 31 here

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

Sidebar

Related Questions

I can run Bash shell commands from with a Ruby program or irb using
In Ruby I can call methods with array elements used as positional parameters like
In ruby, is it possible to specify to call another ruby script using the
I would like to allow users to call my ruby on rails app as
If self is the default receiver in ruby and you call 'puts' in an
In Ruby I think you can call a method that hasn't been defined and
In Ruby, you can call Enumerable#any? on a enumerable object to see if any
In Ruby, how do you call a class method from one of that class's
How do I call a method from a class in a ruby gem? i.e.
I am using jQuery to make an AJAX call to a ruby method in

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.