phyver / GameShell

a game to learn (or teach) how to use standard commands in a Unix shell
GNU General Public License v3.0
2.12k stars 135 forks source link

Mission 29, fails for wrong process name #104

Closed Mte90 closed 2 years ago

Mte90 commented 2 years ago

immagine immagine As you can see in these screens the daemon process is generated with a name truncated so the auto system is not working as fails. Or manually fails because don't find the daemon but instead it's there. Maybe as name is too much longer for the process?

https://github.com/phyver/GameShell/blob/master/missions/processes/03_pstree_kill/init.sh#L57

Mte90 commented 2 years ago

I see this on verbose:

gcc -std=c99 -Wall -Wextra -pedantic /home/mte90/Desktop/Prog/GameShell/gameshell/missions/processes/03_pstree_kill/process.c -o /home/mte90/Desktop/Prog/GameShell/gameshell/.tmp/demone_malizioso
/home/mte90/Desktop/Prog/GameShell/gameshell/missions/processes/03_pstree_kill/spell.c:30: error: unterminated #else
   30 | #ifndef GSH_NO_GETTEXT
      | 
/home/mte90/Desktop/Prog/GameShell/gameshell/missions/processes/03_pstree_kill/spell.c:30: error: unterminated #else
   30 | #ifndef GSH_NO_GETTEXT
      | 
    GSH: sourcing $GSH_ROOT/missions/processes/03_pstree_kill/deps.sh
GSH: environment modifications while sourcing $GSH_ROOT/missions/processes/03_pstree_kill/deps.sh
+Function:_mission_init
+Process: 284700 sleep
GSH: environment modifications while sourcing $GSH_ROOT/missions/processes/03_pstree_kill/init.sh
Mte90 commented 2 years ago

There is any update for this?

phyver commented 2 years ago

No, sorry. I remember dealing with truncated lines at some point, but I have yet to check where, and how.

phyver commented 2 years ago

OK, I think I understand what happens. ps and pstree truncate the process name to 15 characters.

"demone_malizioso" is thus 1 character too long! ("mischievous_imp" was exactly 15 characters long, so I never saw the problem.)

Asking for the commandline (with ps -f) rather than the process name gives the full path to the executable and it is not truncated. I don't like that solution because

The easiest fix would be to replace demone_malizioso by a process name that is less than 15 characters!

A better fix would be to design another mission to illustrate processes hierarchy, but I'm not going to do that anytime soon.

What do you think?

Mte90 commented 2 years ago

I see, the problem in my case is that malizioso has all the synonyms in italian of the same length...

I should change the word with something similar like rogue/rascal but I think that is not the same thing.

Here seems that is possible to get the whole process name with ps https://askubuntu.com/questions/717919/how-to-prevent-ps-from-truncating-the-process-name Otherwise a solution is to look for a process that start with that string.

phyver commented 2 years ago

Here seems that is possible to get the whole process name with ps https://askubuntu.com/questions/717919/how-to-prevent-ps-from-truncating-the-process-name

Not really, that's the equivalent to using ps -f, which I really don't like.

Otherwise a solution is to look for a process that start with that string.

Ahah... Does dc688dcb, on your branch, work with you?

Mte90 commented 2 years ago

Tested with the latest changes on my branch is still failing:

Hai ucciso il demone?

Spiacente, ma la missione 29 non é stata completata.

/home/mte90/Desktop/Prog/GameShell/gameshell/missions/processes/03_pstree_kill/clean.sh: riga 5: 252385 Ucciso                  "$GSH_TMP/$(gettext "nice_fairy")"
Killed
phyver commented 2 years ago

Crap, it seems to work with me. Do you have commit dc688dcb?

Do gsh test and gsh auto fail too? (from the repository)

Mte90 commented 2 years ago

It is working, it was my fault that I didn't generated a new archive.

phyver commented 2 years ago

Perfect! Let's keep this in your branch.