Interrupted system call for posix_memalign
I am getting this exception with posix_memalign. Any idea开发者_开发百科 as to why we get it?
Thanks in advance.
Interrupted system calls are usually the result of a system call being interrupted. In other words, the process is receiving a signal while the call is executing.
The issue is resolved: The thing is the alignment boundary should be a multiple of 2 and sizeof(void *)
. So if posinter size is 4 bytes, the second argument should be 4, 8, 16 etc. Instead of that i was putting it as only multiple of 2, and hence it was crashing.
Wrong usage: crashes
posix_memalign(&addr, 2, 8);
Correct usage:
posix_memalign(&addr, 4, 8); // Second argument multiple of void* and 2
精彩评论