Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

PSP manipulation from DPMI programs (Developers)

posted by tkchia Homepage, 17.02.2023, 11:07
(edited by tkchia on 17.02.2023, 13:54)

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:

Back to the forum
Board view  Mix view
22049 Postings in 2034 Threads, 396 registered users, 85 users online (0 registered, 85 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum