What is waitpid?

Поделиться
HTML-код
  • Опубликовано: 7 янв 2021
  • Source code can be found here:
    code-vault.net/lesson/cq9yhdt...
    ===== Support us through our store =====
    code-vault.net/shop
    ===== Check out our website =====
    code-vault.net
    ===== Check out our Discord server =====
    discord.code-vault.net

Комментарии • 31

  • @Fleeemo
    @Fleeemo 2 года назад +23

    You helped me in 15 minutes with two videos to understand what my professor couldnt explain me in 2 hours. Thank you!

  • @novigradmerchant2400
    @novigradmerchant2400 3 года назад +6

    Yaaay back to the unix processes. My favourite 2 serieses unix threads and unix processes. Thx keep going. You're the beast 😘

  • @xigong3009
    @xigong3009 2 года назад +1

    Thanks for this great lecture! Intiailly I worried the double fork() might compllcate things, but then I realized that the return value inside each child makes the branch looks like " ----/---/----/ ".

  • @bsgamer5069
    @bsgamer5069 3 года назад +10

    I got the job.

    • @CodeVault
      @CodeVault  3 года назад +6

      Congratulations!

    • @bsgamer5069
      @bsgamer5069 3 года назад +6

      @@CodeVault thank you sir. One step towards my dream. One day I will be programming for Elon Musk 😅😅.

    • @SureshKumar-dt1sl
      @SureshKumar-dt1sl 3 года назад +1

      @@bsgamer5069 what kind of job brother? Due to this tutorial? Than its great congrats...

    • @bsgamer5069
      @bsgamer5069 3 года назад +5

      @@SureshKumar-dt1sl I got the job as a programmer mostly backend using c# mostly.

  • @SuyDesignz
    @SuyDesignz 9 месяцев назад

    Thank you for the video! I have another question because you mentioned at the beginning that this is possible with child processes. If I use waitpid with different processes, such as MPI processes, can I still use it? (to wait for MPI processes) Signals, etc. also work without the process needing to be a child.

    • @CodeVault
      @CodeVault  9 месяцев назад +1

      waitpid only works on a child process (from the docs linux.die.net/man/2/waitpid

  • @Manas09rai
    @Manas09rai 3 года назад

    Hey I am having a small issue while trying out your programs on visual studio code, the sys/wait library isn't showing up. Is this library available for Windows or do I have to install linux for this?

    • @CodeVault
      @CodeVault  3 года назад +1

      It's only for Linux. You might be able to get this running using WSL

  • @tungbigbang98
    @tungbigbang98 2 года назад +2

    THANK YOU THANK YOU THANK YOU!

  • @leroi804
    @leroi804 Год назад

    Only the calling thread is waiting on the process? So if I have the main thread and create a new thread before fork and waitpid. That newly created thread keeps executing and isn't influenced by the main thread calling waitpid on the forked process. Is this correct? I'm trying to implement waitpid myself on system level and I'm not completely sure about this.

    • @CodeVault
      @CodeVault  Год назад +1

      waitpid only makes the caller wait for a child process to stop executing. Also, if you actually mean threads instead of processes then waitpid would wait on both threads if it's called on both threads. If it's just a child process, since it doesn't have any, it will simply return

    • @leroi804
      @leroi804 Год назад

      @@CodeVault thanks👍🏼

  • @bahbrahim711
    @bahbrahim711 Год назад

    do u have anything about Competitor Access in C
    ?

    • @CodeVault
      @CodeVault  Год назад

      I'm not sure what you mean exactly. Can you send my some links or an example?

  • @joew4720
    @joew4720 26 дней назад

    didnt get the 2nd fork() because its its not in the father block of code i mean both father and child will execute it this will lead to 4 childs instead of 3 ?

    • @CodeVault
      @CodeVault  23 дня назад +1

      The child process won't execute the 2nd fork() simply because there is a return statement in its if block (so it just exits before it gets to the fork() statement)

    • @joew4720
      @joew4720 23 дня назад +1

      @@CodeVault got it thank you

  • @kalitapatrycja
    @kalitapatrycja 3 года назад

    Can you make film about termios?

    • @CodeVault
      @CodeVault  3 года назад +1

      Seems very specific, I'll see what I can do

  • @Magomedrasul7
    @Magomedrasul7 2 года назад

    Спасибо за содержательные уроки !)

  • @user-mb4ft4xt7q
    @user-mb4ft4xt7q 4 месяца назад

    What behavior when not executioning wait() then end child process then executed wait(). so wait() will wait for non-existent process. How to prevent this case. i need help

    • @CodeVault
      @CodeVault  4 месяца назад

      Yes. wait() does wait for non-existent processes since it also releases any resources related to that process, that's why it's recommended to always wait for the child processes to finish their execution (note: modern OSes do clear resources even if wait() is not called). You can check if the process hasn't finished execution by adding the flag WNOHANG to waitpid but not the other way around.
      What is the use-case for this?

  • @SekhonSatinder
    @SekhonSatinder Год назад

    I am totally different results on macos :(

    • @CodeVault
      @CodeVault  Год назад

      Seems like on MacOS the WNOHANG option doesn't exist for waitpid. Otherwise, everything works the same. Just replace WNOHANG with 0, although the calls will no longer return immediately
      Here's the documentation: developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/waitpid.2.html