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 7502415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T20:51:51+00:00 2026-05-29T20:51:51+00:00

It seems that somewhere between sudo 1.7.2p2 and 1.7.4p5 the behaviour for waiting for

  • 0

It seems that somewhere between sudo 1.7.2p2 and 1.7.4p5 the behaviour for waiting for executing processes has changed. It looks like in the older versions sudo would start the new process, and then quit. In the newer versions it starts the new process, and then waits for it. There is a bit of a discussion about it here: http://www.sudo.ws/pipermail/sudo-users/2010-August/004461.html which mentions that it is to stop it from breaking PAM session support.

This change is breaking one of my scripts which uses sudo to execute commands in the background, as with the older version sudo the command I want to execute would be backgrounded, and with the new version it is sudo itself that is backgrounded.

For example, the process returned by $! in this case is for sleep

user@localhost$ sudo -V
Sudo version 1.7.2p2
user@localhost$ sudo -u poweruser sleep 60 &
[1] 17491
user@localhost$ ps -fp $!
UID        PID  PPID  C STIME TTY          TIME CMD
poweruser 17491 17392  0 16:43 pts/0    00:00:00 sleep 60

Whereas in this case it is for sudo

user@localhost$ sudo -V
Sudo version 1.7.4p5
user@localhost$ sudo -u poweruser sleep 60 &
[1] 792
user@localhost$ ps -fp $!
UID        PID  PPID  C STIME TTY          TIME CMD
root       792 29257  0 16:42 pts/3    00:00:00 sudo -u poweruser sleep 60

Is it possible to get the process ID for a child process executed by sudo version 1.7.4p5? The $! variable returns the PID for sudo, and running sudo with the -b option doesn’ seem to make the child PID available. Is it possible (without recompiling sudo) to revert the behaviour of sudo to stop it from waiting for child processes?

Thanks

  • 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-29T20:51:56+00:00Added an answer on May 29, 2026 at 8:51 pm

    This is certainly a hack, and it doesn’t set $!, but you can echo the pid of the command:

    $ sudo sh -c 'echo $$; exec sleep 60'
    

    I’m guessing that your explanation of the old behavior is not quite right and that sudo simply exec’d the command rather than forking and exiting. Echoing the pid and then exec’ing the desired command might work for you, but you may need creative redirections. For example:

    #!/bin/sh
    
    exec 3>&1
    pid=$( sudo sh -c 'echo $$; exec sh -c "{ sleep 1;
        echo my pid is $$; }" >&3 &')
    echo Child pid is $pid
    

    In the above, you lose the pid of sudo…but it wouldn’t be too hard to find it.

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

Sidebar

Related Questions

It seems that when a WPF application starts, nothing has focus. This is really
It seems that when we use form_for @story do |f| then Story has to
I am in need of a Generic collection that is somewhere in between a
I've got a sqlite table actions that looks something like this: uuid varchar (36)
I'm following this tutorial on WCF and everything works fine. Seems like with that
Seems that even after unchecking the option in the PyDev/Debug preferenecs pane to launch
It seems that in a standard Xcode project, the default target automatically updates the
It seems that using Critical Sections quite a bit in Vista/Windows Server 2008 leads
It seems that MSMQ doesn't use any Database management system to manage messages. How
It seems that there are several really fast prime factorization algorithms around (one that

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.