Drop main() prototype. Syncs with NetBSD-8
[minix.git] / minix / kernel / system / do_exec.c
blobf97901c36c7ca05a0e7664e8dec97b27b1ff0dd0
1 /* The kernel call implemented in this file:
2 * m_type: SYS_EXEC
4 * The parameters for this kernel call are:
5 * m_lsys_krn_sys_exec.endpt (process that did exec call)
6 * m_lsys_krn_sys_exec.stack (new stack pointer)
7 * m_lsys_krn_sys_exec.name (pointer to program name)
8 * m_lsys_krn_sys_exec.ip (new instruction pointer)
9 * m_lsys_krn_sys_exec.ps_str (struct ps_strings *)
11 #include "kernel/system.h"
12 #include <string.h>
13 #include <minix/endpoint.h>
15 #if USE_EXEC
17 /*===========================================================================*
18 * do_exec *
19 *===========================================================================*/
20 int do_exec(struct proc * caller, message * m_ptr)
22 /* Handle sys_exec(). A process has done a successful EXEC. Patch it up. */
23 register struct proc *rp;
24 int proc_nr;
25 char name[PROC_NAME_LEN];
27 if(!isokendpt(m_ptr->m_lsys_krn_sys_exec.endpt, &proc_nr))
28 return EINVAL;
30 rp = proc_addr(proc_nr);
32 if(rp->p_misc_flags & MF_DELIVERMSG) {
33 rp->p_misc_flags &= ~MF_DELIVERMSG;
36 /* Save command name for debugging, ps(1) output, etc. */
37 if(data_copy(caller->p_endpoint, m_ptr->m_lsys_krn_sys_exec.name,
38 KERNEL, (vir_bytes) name,
39 (phys_bytes) sizeof(name) - 1) != OK)
40 strncpy(name, "<unset>", PROC_NAME_LEN);
42 name[sizeof(name)-1] = '\0';
44 /* Set process state. */
45 arch_proc_init(rp,
46 (u32_t) m_ptr->m_lsys_krn_sys_exec.ip,
47 (u32_t) m_ptr->m_lsys_krn_sys_exec.stack,
48 (u32_t) m_ptr->m_lsys_krn_sys_exec.ps_str, name);
50 /* No reply to EXEC call */
51 RTS_UNSET(rp, RTS_RECEIVING);
53 /* Mark fpu_regs contents as not significant, so fpu
54 * will be initialized, when it's used next time. */
55 rp->p_misc_flags &= ~MF_FPU_INITIALIZED;
56 /* force reloading FPU if the current process is the owner */
57 release_fpu(rp);
58 return(OK);
60 #endif /* USE_EXEC */