1 /* The kernel call implemented in this file:
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"
13 #include <minix/endpoint.h>
17 /*===========================================================================*
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
;
25 char name
[PROC_NAME_LEN
];
27 if(!isokendpt(m_ptr
->m_lsys_krn_sys_exec
.endpt
, &proc_nr
))
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. */
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 */