Handle process arguments

This commit is contained in:
2025-09-10 23:25:03 +02:00
parent 2f9f4d9397
commit dc3d80d707
13 changed files with 127 additions and 23 deletions

View File

@ -30,10 +30,12 @@ void main(void) {
uprintf("Hello world using uprintf\n");
int32_t tb = processctl(-1, PCTL_SPAWN, (uint64_t)"base:/bin/tb");
ipcpipe(tb, IPCPIPE_OUT, IPCPIPE_REPLACE, (uint8_t *)(uint64_t)processctl(-1, PCTL_GETPID, 0), IPCPIPE_OUT);
processctl(tb, PCTL_RUN, 0);
while(processctl(tb, PCTL_POLLSTATE, 0) != 2);
const char *tbargs[] = { "-i" };
int32_t tb = processctl(-1, PCTL_SPAWN, (uint64_t)"base:/bin/tb", (uint64_t)tbargs, 1);
uint64_t selfpid = (uint64_t)processctl(-1, PCTL_GETPID, 0, 0, 0);
ipcpipe(tb, IPCPIPE_OUT, IPCPIPE_REPLACE, (uint8_t *)selfpid, IPCPIPE_OUT);
processctl(tb, PCTL_RUN, 0, 0, 0);
while(processctl(tb, PCTL_POLLSTATE, 0, 0, 0) != 2);
if (ipcpipe(IPCPIPE_SELFPID, 10, IPCPIPE_MAKE, NULL, 0) < 0) {
uprintf("failed to create 10th pipe\n");

View File

@ -1,11 +1,12 @@
#include <uprintf.h>
#include <dlmalloc/malloc.h>
#include <args.h>
void main(void) {
uprintf("Hello from tb!\n");
int *tmp = dlmalloc(sizeof(*tmp) * 1024);
*tmp = 123456;
uprintf("*tmp = %d\n", *tmp);
dlfree(tmp);
for (size_t i = 0; i < argslen(); i++) {
uprintf("i = %d\n", i);
uprintf("arg: %s\n", args()[i]);
}
}