Giter Site home page Giter Site logo

Consider exec'ing Argcfile about argc HOT 7 CLOSED

sigoden avatar sigoden commented on May 27, 2024
Consider exec'ing Argcfile

from argc.

Comments (7)

sigoden avatar sigoden commented on May 27, 2024

@CGamesPlay
I don't understand what you said.

fish runs argc
argc locates Argcfile.sh and runsbash Argcfile.sh
bash does the rest

Which part needs improvement?

from argc.

CGamesPlay avatar CGamesPlay commented on May 27, 2024

Instead of running bash Argcfile.sh as a subcommand, it should exec bash Argcfile.sh. This would replace the argc process with the bash process. The desired process tree would look like this:

$ ps uf
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
ubuntu      2034  0.1  0.0 247380 17112 pts/1    Ss   10:40   0:06 -fish
ubuntu     36430  1.0  0.0   8664  5436 pts/1    S+   11:53   0:00  \_ bash

from argc.

sigoden avatar sigoden commented on May 27, 2024

Three is no way to get rid of argc process in the ps tree.

Bash is invoked outside of the script, no exec exists.

from argc.

CGamesPlay avatar CGamesPlay commented on May 27, 2024

Yes, bash is invoked by argc as a child process. The request is to exec the process instead of spawning it. Basically, switch to exec instead of status. By using exec, the argc process itself is replaced by bash. Then the Argcfile.sh can exec another bash, resulting in the desired ps tree.

from argc.

sigoden avatar sigoden commented on May 27, 2024

Does exec return exit statuscode?

from argc.

CGamesPlay avatar CGamesPlay commented on May 27, 2024

No, it actually doesn't return at all. The argc process would be entirely replaced by the target command. However, because the process is replaced in-place, the parent of argc will continue waiting for the new process, and will receive the exit code from the new process once the new process finishes.

from argc.

CGamesPlay avatar CGamesPlay commented on May 27, 2024

Fantastic! Thank you 🙂

from argc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.