marimlem / minishell

0 stars 0 forks source link

bug: CTRL D doesn't close #44

Closed marimlem closed 3 months ago

marimlem commented 3 months ago

have to exit twice even though just opened once ????

====

lknobloc@c3r6p6:~/Documents/minishell$ make v valgrind --suppressions=supp.supp --track-origins=yes --leak-check=full --show-leak-kinds=all ./minishell ==2319821== Memcheck, a memory error detector ==2319821== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==2319821== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info ==2319821== Command: ./minishell ==2319821== minishell:$ << o

minishell: warning: here-document delimited by end-of-file instead of given delimiter minishell:$ echo $? 0 minishell:$ exit ==2319822== ==2319822== HEAP SUMMARY: ==2319822== in use at exit: 208,268 bytes in 228 blocks ==2319822== total heap usage: 850 allocs, 622 frees, 239,029 bytes allocated ==2319822== ==2319822== LEAK SUMMARY: ==2319822== definitely lost: 0 bytes in 0 blocks ==2319822== indirectly lost: 0 bytes in 0 blocks ==2319822== possibly lost: 0 bytes in 0 blocks ==2319822== still reachable: 0 bytes in 0 blocks ==2319822== suppressed: 208,268 bytes in 228 blocks ==2319822== ==2319822== For lists of detected and suppressed errors, rerun with: -s ==2319822== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) minishell:$ exit exit minishell ==2319821== ==2319821== HEAP SUMMARY: ==2319821== in use at exit: 208,265 bytes in 228 blocks ==2319821== total heap usage: 850 allocs, 622 frees, 239,057 bytes allocated ==2319821== ==2319821== LEAK SUMMARY: ==2319821== definitely lost: 0 bytes in 0 blocks ==2319821== indirectly lost: 0 bytes in 0 blocks ==2319821== possibly lost: 0 bytes in 0 blocks ==2319821== still reachable: 0 bytes in 0 blocks ==2319821== suppressed: 208,265 bytes in 228 blocks ==2319821== ==2319821== For lists of detected and suppressed errors, rerun with: -s ==2319821== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) lknobloc@c3r6p6:~/Documents/minishell$

marimlem commented 3 months ago

AHA: << o > newfile

rdr without command will do rdr, but need to be exited out of execution loop manually. at the moment they get stuck in the fork and just go back to the minishell loop, not triggering any error message or encountering any exit statement. (the error is not related to exit or ctrl functionality)

marimlem commented 3 months ago

fixed by adding a check before execve if current->arg[0]==NULL