More details on wstatus: man7.org/linux... Check out our Discord server: / discord
Пікірлер: 38
@zyghom2 жыл бұрын
so far I spent literally hours on your channel not done yet so next one goes now your way of explaining really matches my ways of learning ;-)
@albertocaravantesarranz94922 жыл бұрын
1 hour trying to get error codes from a child process and in 5 minutes you gave me the answer. Love your channel :-D
@user-hy1lm2rd9q7 ай бұрын
Been battling with this issue all day today, your video has saved me. Thank you!!
@joroh_4 жыл бұрын
Thank you, very useful courses, keep going sir.
@yassinemakhlouf9907 Жыл бұрын
another problem i faced is the return status gets modulo by 256, so when you return 256 in this case it's actually like you returned 0 and it show "success" even thought "ping" is misspelled
@CodeVault Жыл бұрын
That's the limit of different exit codes on Linux it seems like. Although there looks to be ways to get the whole 32-bit integer that was returned by the process. Here are more details: stackoverflow.com/questions/179565/exitcodes-bigger-than-255-possible
@lyricsmaker-poplyricsmaker11834 жыл бұрын
You areee really helpingg sir thaanks
@ShannonWare Жыл бұрын
Perhaps you will answer this question later in this series, but I am wondering how to see the exit code when I run main or some other binary from the command line. Especially when I compile and run with VS Code, the 0 from return 0 is not shown in the Terminal. Thanks!
@CodeVault Жыл бұрын
If you run this in bash: echo $? You should get the exit code of the previously executed command
@ShannonWare Жыл бұрын
@@CodeVault that is amazing thank you so much!
@poincareelcartografo5406 Жыл бұрын
But if you misspell the program name (pong instead of ping), you will get the "Could not find the program" message and also the "Success!" message, because the statusCode was 0 even though _execlp() could not find the program.
@CodeVault Жыл бұрын
Interesting, I wonder why it doesn't return a proper error status code. Although, I guess, if you're executing anything after execlp, it already means the call failed and you can print an error message
@user-hg4ef7jm9l6 ай бұрын
I have compiled your code many times, child always returns 1 on success and failure both. I wonder why ...
@CodeVault6 ай бұрын
Make sure you call execlp with valid parameters. Maybe you are missing "ping" from PATH
@Be_Deep_In_Thoughts2 жыл бұрын
I am newbie, so just curious, the wstatus is just an integer right? Can it have a different name or is it a part of some nomenclature to follow?
@CodeVault2 жыл бұрын
The variable's name doesn't matter. And yes it's an integer. wstatus is simply the name of the function's parameter Here you can read up more on this topic: www.man7.org/linux/man-pages/man2/waitpid.2.html
@Be_Deep_In_Thoughts2 жыл бұрын
@@CodeVault Thank you for your response. I follow your videos meticulously and I just love them. Thank you for your quality content.
@ShivamSharma-nb6gh3 жыл бұрын
I want to create a c/c++ program to run MULTIPLE (say 10) c/c++ programs please help 🙏
@abdullahsohail1781 Жыл бұрын
Amaizing--------------------------thanks a lot 🤩
@yassinemakhlouf9907 Жыл бұрын
How to differentiate between the exit code 2 when received from the childprocess because ping was misspelled or the 2 that got returned from the ping program because the domain name was misspelled
@CodeVault Жыл бұрын
You can simply check the return value of exec and then look at errno to find out what exactly happened for the first case and return a different error code than the one returned by ping. Here's more documentation on the topic: linux.die.net/man/2/execve
@migueldomingues68713 жыл бұрын
Hello, can you tell me how I can receive a value from the child process when it receives a signal?! To clarify, the parent sends a signal to the child, and the child should return a pontuatuion (int). Ty, love your videos!
@CodeVault3 жыл бұрын
You can always call read inside the signal handler... although it's not recommended. Signals are not really designed to send/receive data.
@madvillain2853 жыл бұрын
there is a way to execute a command and get the stdout and the exit code? i know i can get the output using popen(), but with this function i can't get the exit code any suggestion, or something I can start from
@CodeVault3 жыл бұрын
You could redirect the standard output to some pipe that then you can do whatever you want with in a parent process, here's a video on this: code-vault.net/lesson/43zvcsz6o1:1603732432539
@madvillain2853 жыл бұрын
@@CodeVault thanks bro, you really help me!
@narendraparmar16313 жыл бұрын
Thanks 😁
@navidnouri1512 жыл бұрын
Thank you a l 000^1000 t!
@ismailskizof1279 Жыл бұрын
thanks from 1337
@miaaaslifestyle95753 жыл бұрын
So the user can click that link and it takes them to google??
@CodeVault3 жыл бұрын
You mean the link google.com? Yes, of course.
@sambanasreeja26063 жыл бұрын
can you do video on semaphore code ?
@CodeVault3 жыл бұрын
Will look into it!
@sparsetable Жыл бұрын
giga brain
@andelephantscanfly3 жыл бұрын
i would be really surprised if your hight is 2m xd xd