[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
This commit is contained in:
rcitachi 2024-08-23 05:53:18 +08:00 committed by GitHub
parent 9d95ad9b8d
commit 9a84c13b2e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 1 deletions

View File

@ -403,6 +403,18 @@ sysret_t sys_setpgid(pid_t pid, pid_t pgid)
if (group == RT_NULL) if (group == RT_NULL)
{ {
group = lwp_pgrp_create(process); group = lwp_pgrp_create(process);
lwp_pgrp_move(group, process);
session = lwp_session_find(sid);
if (session == RT_NULL)
{
LOG_E("the session of sid: %d cannot be found", sid);
err = -EPERM;
goto exit;
}
else
{
lwp_session_insert(session, group);
}
} }
else else
{ {

View File

@ -1229,7 +1229,7 @@ void *sys_mmap2(void *addr, size_t length, int prot,
rc = (sysret_t)lwp_mmap2(lwp_self(), addr, length, prot, flags, fd, pgoffset); rc = (sysret_t)lwp_mmap2(lwp_self(), addr, length, prot, flags, fd, pgoffset);
} }
return (char *)rc + offset; return rc < 0 ? (char *)rc : (char *)rc + offset;
} }
sysret_t sys_munmap(void *addr, size_t length) sysret_t sys_munmap(void *addr, size_t length)