Find the answer to your Linux question:
Results 1 to 7 of 7
In the comments section of this blog , the commenter "Pratik" claims that you can edit a running bash script, without killing it, and have the changes picked up by ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Guru smolloy's Avatar
    Join Date
    Apr 2005
    Location
    CA, but from N.Ireland
    Posts
    2,414

    Alter a running process without killing it


    In the comments section of this blog, the commenter "Pratik" claims that you can edit a running bash script, without killing it, and have the changes picked up by the running script. He claims you can do this by editing files in /proc.

    Now, I know how to find the /proc folder that contains the data on the running process,
    Code:
    cd /proc/`pgrep process_name`
    But I can't figure out what I should do if I want to edit a running bash script.

    Can anyone help me with this?
    Registered Linux user #388328 || Registered LFS user #15880
    AMD 64 X2 4600+ :: 2X1GB DDR2 800 :: GeForce 9400 GT 512MB :: ASUS M2N32 Deluxe :: 4X250GB SATAII
    Need instant help? Try us on IRC -- #linuxforums on freenode

  2. #2
    Linux Guru smolloy's Avatar
    Join Date
    Apr 2005
    Location
    CA, but from N.Ireland
    Posts
    2,414
    I guess this is a bit high-level for most folks (including me)

    Ah well. Thanks for reading
    Registered Linux user #388328 || Registered LFS user #15880
    AMD 64 X2 4600+ :: 2X1GB DDR2 800 :: GeForce 9400 GT 512MB :: ASUS M2N32 Deluxe :: 4X250GB SATAII
    Need instant help? Try us on IRC -- #linuxforums on freenode

  3. #3
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,454
    You can do most anything with Linux, including this, but the gating factor in this case is "how fast can you type?"...

    So, what is the problem you are really trying to solve?
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  4. #4
    Linux Engineer Segfault's Avatar
    Join Date
    Jun 2008
    Location
    Acadiana
    Posts
    877
    SIGHUP will initiate graceful restart, meaning configuration files are re-read. Is this what you want?

  5. #5
    Linux Engineer Segfault's Avatar
    Join Date
    Jun 2008
    Location
    Acadiana
    Posts
    877
    /proc/<PID>/cmdline

    It's the command line right there, never tried to alter it.

    Why don't you try and tell us?

  6. #6
    Linux Guru smolloy's Avatar
    Join Date
    Apr 2005
    Location
    CA, but from N.Ireland
    Posts
    2,414
    Thanks guys.

    Segfault: I tried your suggestion, but it appears that file is unwriteable.

    Maybe the guy who made the original comment was just lying?
    Registered Linux user #388328 || Registered LFS user #15880
    AMD 64 X2 4600+ :: 2X1GB DDR2 800 :: GeForce 9400 GT 512MB :: ASUS M2N32 Deluxe :: 4X250GB SATAII
    Need instant help? Try us on IRC -- #linuxforums on freenode

  7. #7
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,252
    procfs is for getting information about running processes. I believe that it is mostly read-only, and that you cannot modify processes through it. Indeed, according to the proc man page:
    The proc filesystem is a pseudo-filesystem which is used as an interface to kernel data structures. It is commonly mounted at /proc. Most of it is read-only, but some files allow kernel variables to be changed.
    Having said that, it is possible to modify running processes by using a system call called ptrace, which is how gdb works. ptrace allows you to access and modify the memory and registers of a running process. However, doing so meaningfully can be very difficult.

    I cannot see the comment thread of the entry that you posted, but I've certainly never heard of modifying a process through procfs, and even doing so via ptrace would be quite difficult.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •