LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 02-20-2022, 11:18 PM   #1
yvw
LQ Newbie
 
Registered: Feb 2022
Posts: 1

Rep: Reputation: 0
Can read from signalfd return data in not-multiple of sizeof(signalfd_siginfo)? Can read return zero?


Hello,

This is my first post here. The following question was asked, by me, at the StackOverflow wqeb-site. Some days have passed and the qustion did not get enough attention and not a line of text of answer. So I think it is more appropriate to post it here. I should mention that, there is a possibility, that I've already asked this question. But I can not find any references to it in this forum, nor on SO.


Follow is the code that I do to read signalfd:

sock_read is a function that adds number of bytes read to the usual read call. It also does some error checks and interrupt restarts.

Code:
 if((status = sock_read(fd, sigbuf, sizeof(struct signalfd_siginfo) - rb, &n)) < 0) {
  if(status != SOCK_EAGAIN){
   return status;
  }
 }

 if(0 == status){
  return 0; /* can read return zero with signalfd ? */
 }

 if((rb + n) < sizeof(struct signalfd_siginfo)){
  rb += n;
  return 0;
 }
I will make it short. Can read from signalfd return data in not-a-multiple of sizeof(struct signalfd_siginfo)?
And as a subquestion, will read normally return zero?

P.S I understand that read may return ENOMEM(or similar). I think that in the signalfd case, the memory gets passed as is, without some use of lists, buffers and such. But I have zero experience with the following a Linux kernel source code. So this is only my opinion of the way data gets passed.

Last edited by yvw; 02-20-2022 at 11:23 PM. Reason: some edits to make it easier to comprehend a question
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Google “Project Zero” hopes to find zero-day vulnerabilities before the NSA LXer Syndicated Linux News 0 07-16-2014 01:21 PM
sys/signalfd.h missing on Ubuntu ? hwatari Ubuntu 4 08-18-2010 11:44 AM
Firestarter 'Serious' is non-zero, 'Total' is zero sixerjman Linux - Software 0 08-24-2007 12:59 PM
when does sizeof ( ) operator return zero !! joeyBig Programming 3 10-01-2004 06:43 AM
sizeof() return wrong size of structure?? Hammo Programming 7 02-21-2004 04:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 11:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration