Skip to content

Commit 9a84c13

Browse files
authored
[lwp] Implementation of setpgrp and fix mmap2 problems (#9308)
* mmap2 failure handling 当传入一个非常大的地址时,offset会计算得到一个值,又因为传入的地址错误,rc会得到错误码,结合offset会得到一个很奇怪的值。 * Implementation of setpgrp 执行setpgrp会走到这一步,在执行getpgrp无法得到创建的group的值 * Modify the return method of mmap
1 parent 9d95ad9 commit 9a84c13

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Diff for: components/lwp/lwp_pgrp.c

+12
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,18 @@ sysret_t sys_setpgid(pid_t pid, pid_t pgid)
403403
if (group == RT_NULL)
404404
{
405405
group = lwp_pgrp_create(process);
406+
lwp_pgrp_move(group, process);
407+
session = lwp_session_find(sid);
408+
if (session == RT_NULL)
409+
{
410+
LOG_E("the session of sid: %d cannot be found", sid);
411+
err = -EPERM;
412+
goto exit;
413+
}
414+
else
415+
{
416+
lwp_session_insert(session, group);
417+
}
406418
}
407419
else
408420
{

Diff for: components/lwp/lwp_syscall.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1229,7 +1229,7 @@ void *sys_mmap2(void *addr, size_t length, int prot,
12291229
rc = (sysret_t)lwp_mmap2(lwp_self(), addr, length, prot, flags, fd, pgoffset);
12301230
}
12311231

1232-
return (char *)rc + offset;
1232+
return rc < 0 ? (char *)rc : (char *)rc + offset;
12331233
}
12341234

12351235
sysret_t sys_munmap(void *addr, size_t length)

0 commit comments

Comments
 (0)