Jump to content


Photo

Error handling in eConsoleAppContainer


  • Please log in to reply
49 replies to this topic

Re: Error handling in eConsoleAppContainer #41 MiLo

  • PLi® Core member
  • 14,042 posts

+298
Excellent

Posted 20 November 2018 - 16:49

I'd omit the "fprintf" when execvp fails, best to exit a.s.a.p. without raising further chances of things going bad (fprintf is an improvement over eDebug though, but still requires some resources), it's the responsibility of the caller to handle the "127" return code.
Real musicians never die - they just decompose

Re: Error handling in eConsoleAppContainer #42 prl

  • Senior Member
  • 36 posts

+2
Neutral

Posted 21 November 2018 - 01:44

There is little in the way of error handling in most uses of eConsoleAppContainer, whether used directly by the Python code or via Components.Console. I thought it useful to provide as much error feedback as reasonable in the hope that something might get displayed by the class user.

 

Would something like:

		char fail_str[] = "Failed to run ";
        	write(2, fail_str, sizeof fail_str - 1);
		write(2, cmd, strlen(cmd));
		write(2, " - ", 3);
		write(2, strerror(errno), strlen(strerror(errno)));
		write(2, "\n", 1);

be OK?



Re: Error handling in eConsoleAppContainer #43 MiLo

  • PLi® Core member
  • 14,042 posts

+298
Excellent

Posted 21 November 2018 - 09:05

That'd even be worse. At this point, you're still blocking the main thread (vfork, remember?), so you'd want to do as little as possible. Don't output anything, just die as quick as possible and return that error code.
Real musicians never die - they just decompose

Re: Error handling in eConsoleAppContainer #44 prl

  • Senior Member
  • 36 posts

+2
Neutral

Posted 21 November 2018 - 22:58

"Blocking the main thread?" for 5 tiny writes? Shall I time how long they take?



Re: Error handling in eConsoleAppContainer #45 littlesat

  • PLi® Core member
  • 56,123 posts

+685
Excellent

Posted 21 November 2018 - 23:45

Unless this it is not done...

WaveFrontier 28.2E | 23.5E | 19.2E | 16E | 13E | 10/9E | 7E | 5E | 1W | 4/5W | 15W


Re: Error handling in eConsoleAppContainer #46 MiLo

  • PLi® Core member
  • 14,042 posts

+298
Excellent

Posted 22 November 2018 - 11:47

"Blocking the main thread?" for 5 tiny writes? Shall I time how long they take?


It's about how long they *might* take. Writing to a file handle *may* block indefinitely. I can create a situation where something like "int *i; *i++;" takes about 2 seconds to complete. Exceptional, yes. But it does happen.

The point is, something's wrong, and you don't want to make it worse. If that execvp failed for any other reason than the executable being not executable, all you want to do is exit that process as quickly as possible and give the OS the chance to clean up the mess.
Real musicians never die - they just decompose

Re: Error handling in eConsoleAppContainer #47 Erik Slagter

  • PLi® Core member
  • 46,951 posts

+541
Excellent

Posted 22 November 2018 - 20:40

And RTFM as well. Check what vfork() is all about. You really can't do anything between the vfork() and the execve(). It's very clearly stated. If there wasn't such a restriction, we would be using vfork() all of the time. Everything that comes cheap has it disadvantages. It's not about the time you spend, it's about the amount of shared process memory you change. Every statement adds to it and it's wrong, it will give problems.


* Wavefrontier T90 with 28E/23E/19E/13E via SCR switches 2 x 2 x 6 user bands
I don't read PM -> if you have something to ask or to report, do it in the forum so others can benefit. I don't take freelance jobs.
Ik lees geen PM -> als je iets te vragen of te melden hebt, doe het op het forum, zodat anderen er ook wat aan hebben.


Re: Error handling in eConsoleAppContainer #48 prl

  • Senior Member
  • 36 posts

+2
Neutral

Posted 28 November 2018 - 05:11

What shared process memory do those 5 write statements change?



Re: Error handling in eConsoleAppContainer #49 MiLo

  • PLi® Core member
  • 14,042 posts

+298
Excellent

Posted 28 November 2018 - 17:49

Just take our word for it, please.
Real musicians never die - they just decompose

Re: Error handling in eConsoleAppContainer #50 Erik Slagter

  • PLi® Core member
  • 46,951 posts

+541
Excellent

Posted 28 November 2018 - 19:47

What shared process memory do those 5 write statements change?

Take a look at the assembly output of the C compiler and also watch all libc functions that are called... You'll see not only a few but A LOT.


* Wavefrontier T90 with 28E/23E/19E/13E via SCR switches 2 x 2 x 6 user bands
I don't read PM -> if you have something to ask or to report, do it in the forum so others can benefit. I don't take freelance jobs.
Ik lees geen PM -> als je iets te vragen of te melden hebt, doe het op het forum, zodat anderen er ook wat aan hebben.



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users