Home | Notifications | New Note | Local | Federated | Search | Logout
Note Detail
π¦@aaa (2026-05-07 04:02:00)
γγγ γγ§η°‘εγͺγ·γ§γ«γδ½γγγγ
while (1) {
printf("$ ");
char buf[256];
fgets(buf, sizeof(buf), stdin);
buf[strcspn(buf, "\n")] = 0; // Remove \n
char *args[10];
int i = 0;
char *token = strtok(buf, " ");
while (token && i < 9) {
args[i++] = token;
token = strtok(NULL, " ");
}
args[i] = NULL; // NULL-terminate
if (fork() == 0) { // Child
execvp(args[0], args);
perror("execvp");
} else { // Parent
int status;
waitpid(-1, &status, 0);
if (status != 0) {
printf("exited with %d\n", WEXITSTATUS(status));
}
}
}
$ ls --color=auto /
bin dev home initrd.img.old lib32 lost+found mnt proc run srv tmp var vmlinuz.old
boot etc initrd.img lib lib64 media opt root sbin sys usr vmlinuz
$ ls /root
ls: γγ£γ¬γ―γγͺ '/root' γιγγγ¨γεΊζ₯γΎγγ: 許ε―γγγγΎγγ
exited with 2
$ sl
execvp: No such file or directory
Reply
---Replies---
arce@arce (2026-05-07 04:44:49)
Opened up #tinyap and saw all this code stuff. Scary! :)