Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 98bb787

Browse filesBrowse files
yixinghua121unicornx
authored andcommitted
lwp: add softtime support sigval
We have a PR: RT-Thread#10057 submitted, but note it's a bit different against this patch. For example: - changes for lwp.c is not submitted. - changes for ctime.c is a bit different.
1 parent 49fee23 commit 98bb787
Copy full SHA for 98bb787

File tree

4 files changed

+33
-4
lines changed
Filter options

4 files changed

+33
-4
lines changed

‎components/libc/compilers/common/ctime.c

Copy file name to clipboardExpand all lines: components/libc/compilers/common/ctime.c
+16-3Lines changed: 16 additions & 3 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,19 @@ 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();
864-
865-
ret = lwp_signal_kill(lwp, data->signo, SI_TIMER, 0);
872+
ext = rt_malloc(sizeof(struct lwp_siginfo_ext));
873+
if (ext)
874+
{
875+
ext->sigval = data->sigval;
876+
}
877+
ret = lwp_signal_kill(lwp, data->signo, SI_TIMER, ext);
866878
if (lwp)
867879
lwp_ref_dec(lwp);
868880

@@ -907,6 +919,7 @@ static void rtthread_timer_wrapper(void *timerobj)
907919
int tid = *(int *)ptid;
908920
struct lwp_timer_event_param *data = rt_container_of(timer->work, struct lwp_timer_event_param, work);
909921
data->signo = timer->sigev_signo;
922+
data->sigval = timer->val;
910923

911924
if (!tid)
912925
{

‎components/lwp/lwp.c

Copy file name to clipboardExpand all lines: components/lwp/lwp.c
+10-1Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,12 @@ pid_t lwp_execve(char *filename, int debug, int argc, char **argv, char **envp)
465465
return -ENOMEM;
466466
}
467467
#endif
468+
char *argv_last = argv[argc - 1];
469+
int bg = 0;
470+
if (argv_last[0] == '&' && argv_last[1] == '\0')
471+
{
472+
bg = 1;
473+
}
468474

469475
if ((aux = argscopy(lwp, argc, argv, envp)) == RT_NULL)
470476
{
@@ -479,7 +485,10 @@ pid_t lwp_execve(char *filename, int debug, int argc, char **argv, char **envp)
479485
rt_thread_t thread = RT_NULL;
480486
rt_uint32_t priority = 25, tick = 200;
481487

482-
lwp_execve_setup_stdio(lwp);
488+
if (bg == 0)
489+
{
490+
lwp_execve_setup_stdio(lwp);
491+
}
483492

484493
/* obtain the base name */
485494
thread_name = strrchr(filename, '/');

‎components/lwp/lwp_signal.c

Copy file name to clipboardExpand all lines: components/lwp/lwp_signal.c
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,8 @@ RT_STATIC_ASSERT(lp_width_same, sizeof(void *) == sizeof(long));
342342
rt_inline void siginfo_k2u(lwp_siginfo_t ksigi, siginfo_t *usigi)
343343
{
344344
int signo = ksigi->ksiginfo.signo;
345+
346+
memset(usigi, 0, sizeof(siginfo_t));
345347
usigi->si_code = ksigi->ksiginfo.code;
346348
usigi->si_signo = signo;
347349
usigi->si_pid = ksigi->ksiginfo.from_pid;
@@ -354,6 +356,10 @@ rt_inline void siginfo_k2u(lwp_siginfo_t ksigi, siginfo_t *usigi)
354356
usigi->si_utime = ksigi->ext->sigchld.stime;
355357
usigi->si_stime = ksigi->ext->sigchld.utime;
356358
}
359+
else
360+
{
361+
usigi->si_value = ksigi->ext->sigval;
362+
}
357363
}
358364

359365
/* deprecated field */

‎include/rtdef.h

Copy file name to clipboardExpand all lines: include/rtdef.h
+1Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.