PSP manipulation from DPMI programs (Developers)
Hello Laaca,
> I see! I understood why you think that I should reimplement the Exec
> function.
> Under Turbopascal the Exec copies the environment for child from _actual_
> PSP/environment.
> So in our case we do not have to change the Exec (int 21h/4b00h)
> implementation because it is enough to change PSP.
You are (still) overthinking this (in my opinion). What I would propose is to implement a procedure that is sort of like Exec()
but allows you to explicitly say what environment variables you want inside the child process, e.g.
procedure ExecWithEnv(
const path: PathStr;
const comline: ComStr;
const childenv: Array [1..$7fff] of String[255]
);
(OK, childenv
should really be a variable-length array. But I am not sure how to specify those in Free Pascal. And anyway you get the basic idea.)
Currently Exec()
sets the child process's environment from the parent process:
{ copy environment }
for i:=1 to envcount do
paste_to_dos(envstr(i),false,false);
But it does not have to do that! You can get it to read environment variables from a different place altogether, e.g.
{ set child environment }
for i:=1 to $7fff do
if childenv[i] <> '' then
paste_to_dos(childenv[i], false, false);
Then wham, the child will get its environment from the childenv[]
array instead. This is basically how things are done when coding in C.
(You will need make sure that childenv[]
does not contain multiple settings for the same environment variable.)
Thank you!
---
https://gitlab.com/tkchia · https://codeberg.org/tkchia · 😴 "MOV AX,0D500H+CMOS_REG_D+NMI"
Complete thread:
- PSP manipulation from DPMI programs - Laaca, 16.02.2023, 00:02
- PSP manipulation from DPMI programs - Japheth, 16.02.2023, 05:25
- PSP manipulation from DPMI programs - tkchia, 16.02.2023, 11:18
- PSP manipulation from DPMI programs - Laaca, 16.02.2023, 19:46
- PSP manipulation from DPMI programs - tom, 16.02.2023, 20:16
- PSP manipulation from DPMI programs - Laaca, 16.02.2023, 20:48
- PSP manipulation from DPMI programs - tkchia, 16.02.2023, 21:23
- PSP manipulation from DPMI programs - tkchia, 16.02.2023, 21:28
- PSP manipulation from DPMI programs - tkchia, 16.02.2023, 21:35
- PSP manipulation from DPMI programs - Rugxulo, 17.02.2023, 08:35
- PSP manipulation from DPMI programs - tkchia, 17.02.2023, 11:21
- PSP manipulation from DPMI programs - marcov, 17.02.2023, 16:00
- PSP manipulation from DPMI programs - tkchia, 17.02.2023, 11:21
- PSP manipulation from DPMI programs - Laaca, 17.02.2023, 08:56
- PSP manipulation from DPMI programs - tkchia, 17.02.2023, 11:07
- PSP manipulation from DPMI programs - Laaca, 18.02.2023, 00:52
- PSP manipulation from DPMI programs - marcov, 17.02.2023, 16:02
- PSP manipulation from DPMI programs - tkchia, 17.02.2023, 11:07
- PSP manipulation from DPMI programs - Rugxulo, 17.02.2023, 08:35
- PSP manipulation from DPMI programs - tom, 16.02.2023, 20:16
- PSP manipulation from DPMI programs - Laaca, 16.02.2023, 19:46
- PSP manipulation from DPMI programs - tkchia, 16.02.2023, 11:26
- PSP manipulation from DPMI programs - tkchia, 16.02.2023, 17:14