Request for review: 6749267: Signal handler should save/restore errno
harold seigel
harold.seigel at oracle.com
Mon Feb 18 12:29:12 PST 2013
Hi Serguei,
Thanks for reviewing this!
I think that the perror() message will also be preserved. I tried this
with a small C++ program:
#include <stdio.h>
#include <errno.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
int main(int argc, char * argv[]) {
char buf[20];
int old_errno;
int bad_fd = 23;
int res = open("/i/dont/exist", O_RDONLY);
old_errno = errno;
perror("errno: ");
res = read(bad_fd, buf, 10);
perror("errno: ");
errno = old_errno;
perror("errno: ");
return 0;
}
When I ran this program, I got the following result:
% ./a.out
errno: : No such file or directory
errno: : Bad file descriptor
errno: : No such file or directory
Hopefully, our code will behave the same way.
Thanks, Harold
On 2/18/2013 3:10 PM, serguei.spitsyn at oracle.com wrote:
> Looks good.
>
> I'm not sure it is an ultimate solution though.
> The error message that is reported by the perror() might be lost as well,
> but I'm not sure yet if it is possible to restore it as well.
>
> A link:
> http://www.kernel.org/doc/man-pages/online/pages/man3/perror.3.html
>
>
> Thanks,
> Serguei
>
>
>
> On 2/18/13 6:07 AM, harold seigel wrote:
>> Hi,
>>
>> Please review the following change.
>>
>> Summary: With this change, the actual signal handler saves the errno
>> before calling the function that does most of the signal handling
>> processing. It then restores the value of errno when the signal
>> handling processing function returns.
>>
>> Open webrev: http://cr.openjdk.java.net/~hseigel/bug_6749267/
>> <http://cr.openjdk.java.net/%7Ehseigel/bug_6749267/>
>>
>> Bug link at: https://jbs.oracle.com/bugs/browse/JDK-6749267
>>
>> The changes were tested with JPRT, JCK Lang and VM tests, UTE tests,
>> and with JPRT. Also, I used the debugger to change the value of
>> errno inside of the signal handling processing method and then
>> verified that it got restored properly.
>>
>> Thanks! Harold
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/attachments/20130218/16566277/attachment.html
More information about the hotspot-runtime-dev
mailing list