Skip to content

Commit 4e2946f

Browse files
committed
[components][lwp] Add sigaction support siginfo_t
1 parent 58e587b commit 4e2946f

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

components/libc/compilers/common/ctime.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -828,20 +828,27 @@ struct lwp_timer_event_param
828828
pid_t pid;
829829
};
830830
int signo;
831+
union sigval sigval;
831832
};
832833

833834
static void _lwp_timer_event_from_tid(struct rt_work *work, void *param)
834835
{
835836
rt_err_t ret;
836837
struct lwp_timer_event_param *data = rt_container_of(work, struct lwp_timer_event_param, work);
837838
rt_thread_t thread;
839+
lwp_siginfo_ext_t ext;
838840

839841
RT_ASSERT(data->tid);
840842

841843
/* stop others from delete thread */
842844
thread = lwp_tid_get_thread_and_inc_ref(data->tid);
843845
/** The tid of thread is a READ ONLY value, but here still facing the risk of thread already been delete error */
844-
ret = lwp_thread_signal_kill(thread, data->signo, SI_TIMER, 0);
846+
ext = rt_malloc(sizeof(struct lwp_siginfo_ext));
847+
if (ext)
848+
{
849+
ext->sigval = data->sigval;
850+
}
851+
ret = lwp_thread_signal_kill(thread, data->signo, SI_TIMER, ext);
845852
lwp_tid_dec_ref(thread);
846853

847854
if (ret)
@@ -855,14 +862,20 @@ static void _lwp_timer_event_from_pid(struct rt_work *work, void *param)
855862
rt_err_t ret;
856863
struct lwp_timer_event_param *data = rt_container_of(work, struct lwp_timer_event_param, work);
857864
struct rt_lwp *lwp;
865+
lwp_siginfo_ext_t ext;
858866

859867
lwp_pid_lock_take();
860868
lwp = lwp_from_pid_locked(data->pid);
861869
if (lwp)
862870
lwp_ref_inc(lwp);
863871
lwp_pid_lock_release();
864872

865-
ret = lwp_signal_kill(lwp, data->signo, SI_TIMER, 0);
873+
ext = rt_malloc(sizeof(struct lwp_siginfo_ext));
874+
if (ext)
875+
{
876+
ext->sigval = data->sigval;
877+
}
878+
ret = lwp_signal_kill(lwp, data->signo, SI_TIMER, ext);
866879
if (lwp)
867880
lwp_ref_dec(lwp);
868881

components/lwp/lwp_signal.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,8 @@ RT_STATIC_ASSERT(lp_width_same, sizeof(void *) == sizeof(long));
347347
rt_inline void siginfo_k2u(lwp_siginfo_t ksigi, siginfo_t *usigi)
348348
{
349349
int signo = ksigi->ksiginfo.signo;
350+
351+
memset(usigi, 0, sizeof(siginfo_t));
350352
usigi->si_code = ksigi->ksiginfo.code;
351353
usigi->si_signo = signo;
352354
usigi->si_pid = ksigi->ksiginfo.from_pid;
@@ -359,6 +361,10 @@ rt_inline void siginfo_k2u(lwp_siginfo_t ksigi, siginfo_t *usigi)
359361
usigi->si_utime = ksigi->ext->sigchld.stime;
360362
usigi->si_stime = ksigi->ext->sigchld.utime;
361363
}
364+
else
365+
{
366+
usigi->si_value = ksigi->ext->sigval;
367+
}
362368
}
363369

364370
/* deprecated field */

include/rtdef.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,7 @@ typedef struct lwp_siginfo_ext {
804804
clock_t utime;
805805
clock_t stime;
806806
} sigchld;
807+
union sigval sigval;
807808
};
808809
} *lwp_siginfo_ext_t;
809810

0 commit comments

Comments
 (0)