Handling Errors in C/Unix (perror, strerror, errno)

preview_player
Показать описание
---

***

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:



***

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:

To Support the Channel:
+ like, subscribe, spread the word

Want me to review your code?

You can also find more info about code reviews here.
Рекомендации по теме
Комментарии
Автор

Please Jacob do a series of design patterns in C.

Pawlsolidus
Автор

One interesting feature that I learned very recently is that you can use the %m formatter when using printf in replacement for %s plus strerror

Redmat
Автор

That was super helpful and entertaining! :)
It also replaced my bedtime story since I’m about to sleep. Cheers!

YokeRoel
Автор

From my experience, the error handling in C is one of the few cases, where the goto statement is useful. It can just go to the end of the function scope and fall through, thus freeing all the so far allocated memory in a stack based manner.

RobarthVideo
Автор

Subscribed! Notifications to ALL. Mid-corona lockdown, I have set to the task of learning C (go figure, I'm a developer that did'nt get to have C in school...) so this is usefull (and that is an understatement)...lemme have more of this :)

melissarainchild
Автор

Your videos are great, please keep it up

JT-nqvh
Автор

great video, makes hard subjects easy to understand !

slap
Автор

Thank you so very much for your informative

Ricko
Автор

3:35 to 3:47 that's now clear my doubts of why errno is stored and why it's value differ ..in every time before or after function call like opening files or other.
That's really amazing and helpful I was in doubts and confusion about it

Sahilbc-wjqk
Автор

is writing macro better then writing function? Thanks.

InMemoryOfNeo
Автор

Beginner students ignore the internal manual because they have videos like this or the all mighty stack overflow. They are more direct and to the exact point.
I guess the next thing is to ask if that is a bad thing.

Also, you were right about the common pronunciation of errno. But if you were to teach it to students, maybe say error number for clarity.

XenoTravis
Автор

great vid, very helpful.

just a question:
is there a reason to prefer fprint over printf?

benjaminshinar
Автор

I have problem with memory layout in c and how c get interpreted into assembly and interted into memory

iandmetick
Автор

Great video, thanks for all this work!

I got a question:
You mention that macros give you the line number and file name, while a functions give you safety (and a cleaner syntax).

This makes me think that you can write an error-handling function (say, check_func(int val, int lineno, char *filename)), but instead of calling it directly, use a macro (the macro expands to a call to check_func while adding the line number and file name).

Not sure whether that is a good idea...

outrotipo
Автор

does this mean in multithreaded .. i cannot check errorno unless i encapsulate the sys call function inside a critical section ... because maybe other thread will call another syscall and change the error no before i handle it ?

hasanalattar
Автор

When using exit(-1), shouldn't free all the dynamically allocated stuff that you previously have outside the failing function call?

Poeterish
Автор

Is it preferable to use assert instead of the macro?

xpdseth
Автор

Can I use this code as an "C program to generate illegal exception in UNIX"

sheetalray
Автор

what I dont understand is why they use a negative one do indicte a failure. From working with linux and bash and so on, usually the canonical failure code is 1 and not -1.

codingsafari
Автор

You forgot to use the macro on fputc().

maxaafbackname