Making forked clones more useful with exec()!

Sdílet
Vložit
  • čas přidán 28. 01. 2018
  • Patreon ➤ / jacobsorber
    Courses ➤ jacobsorber.thinkific.com
    Website ➤ www.jacobsorber.com
    ---
    ***
    Welcome! I post videos that help you learn to program and become a more confident software developer. I cover beginner-to-advanced systems topics ranging from network programming, threads, processes, operating systems, embedded systems and others. My goal is to help you get under-the-hood and better understand how computers work and how you can use them to become stronger students and more capable professional developers.
    About me: I'm a computer scientist, electrical engineer, researcher, and teacher. I specialize in embedded systems, mobile computing, sensor networks, and the Internet of Things. I teach systems and networking courses at Clemson University, where I also lead the PERSIST research lab.
    More about me and what I do:
    people.cs.clemson.edu/~jsorber/
    persist.cs.clemson.edu/ Note that any Amazon links in my video descriptions are generated by Amazon. If you click one of them and then buy something it helps support this channel. Thanks.
    ***
    Welcome! I post videos that help you learn to program and become a more confident software developer. I cover beginner-to-advanced systems topics ranging from network programming, threads, processes, operating systems, embedded systems and others. My goal is to help you get under-the-hood and better understand how computers work and how you can use them to become stronger students and more capable professional developers.
    About me: I'm a computer scientist, electrical engineer, researcher, and teacher. I specialize in embedded systems, mobile computing, sensor networks, and the Internet of Things. I teach systems and networking courses at Clemson University, where I also lead the PERSIST research lab.
    More about me and what I do:
    www.jacobsorber.com
    people.cs.clemson.edu/~jsorber/
    persist.cs.clemson.edu/
    To Support the Channel:
    + like, subscribe, spread the word
    + contribute via Patreon --- [ / jacobsorber ]
    + rep the channel with nerdy merch --- [teespring.com/stores/jacob-so...]
    Source code is also available to Patreon supporters. --- [jsorber-youtube-source.heroku...]
    Want me to review your code?
    Email the code to js.reviews.code@gmail.com. Code should be simple and in one of the following languages: C, C++, python, java, ruby. You must be the author of the code and have rights to post it. Please include the following statement in your email: "I attest that this is my code, and I hereby give Jacob Sorber the right to use, review, post, comment on, and modify this code on his videos."
    You can also find more info about code reviews here.
    • I want to review your ...

Komentáře • 51

  • @DerNamenLose1222
    @DerNamenLose1222 Před 4 lety +25

    I dont get how you can explain exec() in a 4min vid so much better than my prof in a 1 hour long lecture. Keep up this good work

  • @lungaphakathi9915
    @lungaphakathi9915 Před 3 lety +19

    I am so impressed by your communication skills, even if I didn't have to learn this I would still watch your video.

  • @turqayu3548
    @turqayu3548 Před 4 lety +33

    Best video on this subject ,deserves way more views

    • @JacobSorber
      @JacobSorber  Před 4 lety +2

      I know, right? :)
      Thanks for watching. Glad you enjoyed it.

  • @johnnya590
    @johnnya590 Před 5 lety +25

    This video deserves more views and your channel deserves more followers!
    Keep up these great videos!

  • @oleholgerson3416
    @oleholgerson3416 Před 3 lety

    Thank you for your hard work, keep the videos coming! I‘m learning so much from them.

  • @vikashsinghrawat346
    @vikashsinghrawat346 Před 5 lety +6

    Short and crisp video.. looking for more videos from you.

  • @Sabanar495
    @Sabanar495 Před 4 lety +4

    Thank you for the videos!!!

  • @NicolasCatalani
    @NicolasCatalani Před 3 lety +2

    Remarkable video. It's amazing how you can digest complex concepts into simple analogies.
    As someone with a mec eng background that managed to slip into software engineering, your channel is a blessing. Thanks for the content and keep up the good work!

  • @frankthefrank641
    @frankthefrank641 Před 5 lety +1

    Thanks a lot for this content man! You are clear and concise like few professors can be, keep it up!

    • @JacobSorber
      @JacobSorber  Před 5 lety +1

      Thanks, Frankie. Glad to help. Let me know if there are topics you would like to see on the channel.

  • @MA-ek1xl
    @MA-ek1xl Před 2 lety

    Incredible explanation.

  • @jacksonxie7579
    @jacksonxie7579 Před 4 lety +2

    The best video for c programmer!

  • @selvalooks
    @selvalooks Před rokem

    Good one Boss !!!

  • @munshifahimuzzaman7275

    Jeez... You're amazing!

  • @JorgeVallecillo
    @JorgeVallecillo Před 4 lety +1

    Thanks for your videos, really helpful!

  • @gmailgmail205
    @gmailgmail205 Před 3 lety +2

    THE best, clearest videos around. Any plans for advance/ c++ series?

    • @JacobSorber
      @JacobSorber  Před 3 lety +1

      I have all sorts of plans. Just looking for the time to implement them. 😀

  • @arnavgattani2136
    @arnavgattani2136 Před rokem

    thanks so much

  • @ihorkarpiuk4102
    @ihorkarpiuk4102 Před 4 lety

    u r just the best, subscribed

  • @nikhilkumarsingh3637
    @nikhilkumarsingh3637 Před 6 měsíci

    Love this video❤

  • @mehregankbi
    @mehregankbi Před 3 měsíci

    Note to other Linux learners: While exec does reset the virtual memory space of the initial binary including all text and data, the "task struct" in the Linux kernel memory space, which holds info such as signal handlers, open files, pid, etc., will not change. That's why the process id doesn't change.
    You can change those signal handlers and open files explicitly and in fact, that's how the "nohup" terminal command works. It sets a custom signal handler for the SIGHUP signal and redirects stdin, stdout, and stderr for itself, but when exec is called, the destination binary will inherit these open files and signal handlers which as I said, can be changed again by the destination binary. Because of this, nohup fails to work if the destination binary has its own custom handler for SIGHUP (some apps have this in order to exit gracefully upon receiving this signal) and that's because as soon as the destination binary starts running, it replaces the signal handler set by nohup with the one set by the destination binary.

  • @jackrdye
    @jackrdye Před 3 lety +1

    Absolutely love this explanation. I use Windows and was wondering how to run a similar function to fork/exec. I use python and was wondering if there was a library or something? I am 1st year computer science student and was also wondering if you would suggest just moving to a Linux system? Currently I use git bash and run a vim etc but can be a pain sometimes. Please keep videos like this coming, I just spotted your hexadecimal video and just about to watch it. A series on all things intro to computer science by you would be amazing. Efficiency is key to everything and you explaining things to me(and others) clearly in 5 minutes is much more efficient then not understanding it after an hour long lecture. I hope you continue to grow so you can dedicate more time to this channel. Thanks

    • @jackrdye
      @jackrdye Před 3 lety

      Just looked through you channel I may have missed it but a series on command line would be amazing! Not start to finish, learning it requires us to actually work not just watch CZcams videos but things in the command line you find yourself using regularly and that you think are particularly useful. Or things you think students have misconceptions about. Thanks again

  • @shotophop1929
    @shotophop1929 Před rokem

    I dislike the music on your videos but I do really like how you explain things. Ill stick to your channel and I wonder how the newer videos are made

  • @GurpreetKakar4873
    @GurpreetKakar4873 Před 6 lety +2

    Good video short and concise

  • @thestarinthesky_
    @thestarinthesky_ Před 5 lety +1

    You should be teaching at Harvard University ! You have the potential! The best explanations ever!

  • @bonbonpony
    @bonbonpony Před 3 lety +1

    You know what would make them even more useful? Input/output redirection. You know, so that the parent could capture the output of the child, or send it some data to its standard input. Do you have any videos on that yet?

  • @solutionstate
    @solutionstate Před 4 lety

    why hasn't all OS videos are easily gathered in a playlist?! it is so inconvenient

    • @JacobSorber
      @JacobSorber  Před 4 lety

      Good question. One of life's great mysteries.

  • @ldpenrose
    @ldpenrose Před 2 lety

    This is GOLD! 🏅

  • @markgalperin6959
    @markgalperin6959 Před rokem

    i would like to know , if i fork a child and the on the child i use one of the exec family functions, does the child terminate when it finishes the execution of exec command or does it continue with the rest of the process?
    thank you ver much i love you're content !!

  • @samplesandtests
    @samplesandtests Před 11 měsíci

    with execl() does it need to be the absolute path or can it be the relative path? i have been using it with a relative path for testing (i know if i move the original executable to a different path the relative path will be invalid ), but is the a fluke of my compiler or is this how the execl() function is supposed to work?

  • @coolshakeeb11
    @coolshakeeb11 Před 4 lety +1

    dont think i didnt notice the right harry potter was missing an arm 3:)

    • @JacobSorber
      @JacobSorber  Před 4 lety +1

      Oh, no. You saw it! I guess the cloning process wasn't complete. Poor Harry. :)

  • @inanismailov
    @inanismailov Před 4 lety

    Is it possible to see a more in depth example of how this works? For instance have a process which creates a child process that does something completely different with different types of inputs as well?

    • @JacobSorber
      @JacobSorber  Před 4 lety

      I'm not sure I understand what you're looking for. I did create a child process that did something very different (even though it wasn't complicated) than the parent. Can you be more specific about what you're looking for?

  • @fernandogardeazabal930
    @fernandogardeazabal930 Před 4 lety +1

    "How do I create a child process that runs another program?"

  • @IsaacNewTom22
    @IsaacNewTom22 Před 2 lety

    Why did you list "ls" twice and then the flag "-al"? I've tried running the same code but with only one "ls" and it didn't work

  • @jonaskyman
    @jonaskyman Před 3 lety

    Can those 2 processes (parent and child) communicate, send messages, provide any status between each other?, I might assume they don't.

    • @JacobSorber
      @JacobSorber  Před 3 lety

      Processes can definitely communicate using signals, pipes, named pipes, sockets, shared memory, message passing mechanisms, remote procedure calls, files, and probably other IPC (interprocess communication) methods that aren't immediately coming to mind. I have a few videos on some of these.

  • @HB_
    @HB_ Před 4 lety

    Hello, first thank you for the good job. I runned the same program but did't get the same output: fisrt I get the parent output then the ls by the excec function, I didn't get none of the child ouput. I'm wondering why ?

    • @JacobSorber
      @JacobSorber  Před 4 lety +1

      So, you don't get "I'm childish" before "ls" runs in the child? The "after execlp" shouldn't print out, which is one of the points I am trying to point out. Exec replaces the child so any child code after exec (in the original program) won't execute.

    • @HB_
      @HB_ Před 4 lety

      @@JacobSorber yes the message before exec doesn't work and try to figure why 🤪?
      because in the printf I didn't ask for
      at the end😅. Once I put
      I get the message before exec or without
      only by using puts instead of printf. The question now why we should have a new line before executing exec. What's the relation ?

    • @JacobSorber
      @JacobSorber  Před 4 lety +1

      @@HB_ Ah, makes sense. It has to do with buffering. Printf, doesn't always print immediately to stdout. It adds the output to a buffer, which is pushed (when convenient) to stdout. Different buffering modes are used, but the most common, flushes the buffers whenever a newline is reached. So, basically, the buffer wasn't flushing, and then exec was just blowing everything away and running ls.

    • @HB_
      @HB_ Před 4 lety

      @@JacobSorber Very clear explanation. Thank you very much and please keep doing this great job.