xxyzz / ostep-hw

Operating Systems: Three Easy Pieces(OSTEP) homework and project solutions
GNU General Public License v3.0
763 stars 179 forks source link

update to one more robust Sem_open #21

Closed sci-42ver closed 1 year ago

sci-42ver commented 1 year ago

Maybe the last my pull request is too trivial. Hope this one is not.

If there is something like /dev/shm/sem.lock already due to some problems like the deadlock and then quit forcefully, then sem_open won't create and init as expected.

I added one check before sem_open to solve the problem.

Hope that the author can check my code when he is not busy.

xxyzz commented 1 year ago

Thank you for your contribution!