Re: [LTP] [PATCH v3] Migrating the libhugetlbfs/testcases/truncate.c test

Petr Vorel
2024-03-21T07:35:58Z

> > ...
> > > +static void sigbus_handler(int signum)
> > > +{
> > > + test_pass = 1;
> > > + siglongjmp(sig_escape, 17);
> > What 17 stands for? Is there any constant which could be used? Or can
> > you define
> > something (the name of the constant would be self-describing).
> The value 17 is often chosen as a non-zero return value for sigsetjmp
> because it is unlikely to be a valid return value from a normal
> function. By using a non-zero value, you can distinguish between a
> direct return from sigsetjmp (where the return value is 0) and a return
> after a siglongjmp (where the return value is non-zero).
> By using a non-zero value (like 17), you can differentiate between
> normal function returns and jumps due to exceptional conditions. he
> specific value chosen (such as 17) can vary based on the programmer’s
> preference or the context of the application. Some developers might use
> other non-zero values, but 17 has become a convention due to its
> uniqueness and readability.

Thanks for info!