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! :)