diff --git a/drivers/timers/rtc.c b/drivers/timers/rtc.c index 62453c1c20..0b467fde2f 100644 --- a/drivers/timers/rtc.c +++ b/drivers/timers/rtc.c @@ -384,13 +384,23 @@ static int rtc_ioctl(FAR struct file *filep, int cmd, unsigned long arg) if (ops->setalarm) { + pid_t pid; + + /* A PID of zero means to signal the calling task */ + + pid = alarminfo->pid; + if (pid == 0) + { + pid = getpid(); + } + /* Save the signal info to be used to notify the caller when the * alarm expires. */ upperinfo->active = true; upperinfo->signo = alarminfo->signo; - upperinfo->pid = alarminfo->pid; + upperinfo->pid = pid; upperinfo->sigvalue = alarminfo->sigvalue; /* Format the alarm info needed by the lower half driver */ @@ -447,13 +457,23 @@ static int rtc_ioctl(FAR struct file *filep, int cmd, unsigned long arg) if (ops->setrelative) { + pid_t pid; + + /* A PID of zero means to signal the calling task */ + + pid = alarminfo->pid; + if (pid == 0) + { + pid = getpid(); + } + /* Save the signal info to be used to notify the caller when the * alarm expires. */ upperinfo->active = true; upperinfo->signo = alarminfo->signo; - upperinfo->pid = alarminfo->pid; + upperinfo->pid = pid; upperinfo->sigvalue = alarminfo->sigvalue; /* Format the alarm info needed by the lower half driver */ diff --git a/include/nuttx/timers/rtc.h b/include/nuttx/timers/rtc.h index 179779a213..d2345a4dc1 100644 --- a/include/nuttx/timers/rtc.h +++ b/include/nuttx/timers/rtc.h @@ -223,7 +223,7 @@ struct rtc_setalarm_s { uint8_t id; /* Indicates the alarm to be set */ uint8_t signo; /* Signal number for alarm notification */ - pid_t pid; /* Identifies task to be notified */ + pid_t pid; /* Identifies task to be notified (0=caller) */ union sigval sigvalue; /* Data passed with notification */ struct rtc_time time; /* Alarm time */ }; @@ -234,7 +234,7 @@ struct rtc_setrelative_s { uint8_t id; /* Indicates the alarm to be set */ uint8_t signo; /* Signal number for alarm notification */ - pid_t pid; /* Identifies task to be notified */ + pid_t pid; /* Identifies task to be notified (0=caller) */ union sigval sigvalue; /* Data passed with notification */ time_t reltime; /* Relative time in seconds */ };