syscall_emul.cc (14130:62df30844a66) syscall_emul.cc (14149:9154039407e5)
1/*
2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 987 unchanged lines hidden (view full) ---

996 auto process = tc->getProcessPtr();
997 int pid = process->getSyscallArg(tc, index);
998 int pgid = process->getSyscallArg(tc, index);
999
1000 if (pgid < 0)
1001 return -EINVAL;
1002
1003 if (pid == 0) {
1/*
2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 987 unchanged lines hidden (view full) ---

996 auto process = tc->getProcessPtr();
997 int pid = process->getSyscallArg(tc, index);
998 int pgid = process->getSyscallArg(tc, index);
999
1000 if (pgid < 0)
1001 return -EINVAL;
1002
1003 if (pid == 0) {
1004 process->setpgid(process->pid());
1004 process->pgid(process->pid());
1005 return 0;
1006 }
1007
1008 Process *matched_ph = nullptr;
1009 System *sysh = tc->getSystemPtr();
1010
1011 // Retrieves process pointer from active/suspended thread contexts.
1012 for (int i = 0; i < sysh->numContexts(); i++) {
1013 if (sysh->threadContexts[i]->status() != ThreadContext::Halted) {
1014 Process *temp_h = sysh->threadContexts[i]->getProcessPtr();
1015 Process *walk_ph = (Process*)temp_h;
1016
1017 if (walk_ph && walk_ph->pid() == process->pid())
1018 matched_ph = walk_ph;
1019 }
1020 }
1021
1022 assert(matched_ph);
1005 return 0;
1006 }
1007
1008 Process *matched_ph = nullptr;
1009 System *sysh = tc->getSystemPtr();
1010
1011 // Retrieves process pointer from active/suspended thread contexts.
1012 for (int i = 0; i < sysh->numContexts(); i++) {
1013 if (sysh->threadContexts[i]->status() != ThreadContext::Halted) {
1014 Process *temp_h = sysh->threadContexts[i]->getProcessPtr();
1015 Process *walk_ph = (Process*)temp_h;
1016
1017 if (walk_ph && walk_ph->pid() == process->pid())
1018 matched_ph = walk_ph;
1019 }
1020 }
1021
1022 assert(matched_ph);
1023 matched_ph->setpgid((pgid == 0) ? matched_ph->pid() : pgid);
1023 matched_ph->pgid((pgid == 0) ? matched_ph->pid() : pgid);
1024
1025 return 0;
1026}
1027
1028SyscallReturn
1029getpidPseudoFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
1030{
1031 // Make up a PID. There's no interprocess communication in

--- 810 unchanged lines hidden ---
1024
1025 return 0;
1026}
1027
1028SyscallReturn
1029getpidPseudoFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
1030{
1031 // Make up a PID. There's no interprocess communication in

--- 810 unchanged lines hidden ---