Subject: Re: [ast-developers] Does ksh's builtin interface do garbage 
collection  if a builtin was killed with CTRL-C?
--------

> Does ksh's (we are using 2010-03-05) builtin interface do garbage
> collection if a builtin was killed with CTRL-C, for example are file
> descriptors opened with AST stdio fopen() or plain open() closed or
> does this require extra hooks? Will the shell free allocated memory if
> the builtin didn't do it on exit or will this require extra hooks,
> too?
> 
> Irek
> 

If files are opened with fopen() or sfopen(), then they will be cleaned
up but those open() will not.

If you use the stakalloc( library for memory allocation then all
memory allocated will be released after the built-in completes whether
it fails sor not.

In addition, there are hooks that can be used for cleanup.
For example, if you used the <error.h> header file, there is a
bit that you can set which will cause your builtin to be called
with arc set to -signo when a signal is received.

In addition, if the third argument to the builtin (which is a structure)
has the notify field non-zero, it will set the sigset field when
a signal has come in.  This can be checked by the built-in before
any call that would block and  on failures from slow system calls.

It does take a little more effort to write correct built-ins that
don't leave resources but we have done this for around 40 standard
utilities.  

David Korn
[email protected]


David Korn
[email protected]
_______________________________________________
ast-developers mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-developers

Reply via email to