Skip to content

Resolve some compatibility issues with macOS#5

Open
alerighi wants to merge 6 commits intoveluca93:masterfrom
turingarena:master
Open

Resolve some compatibility issues with macOS#5
alerighi wants to merge 6 commits intoveluca93:masterfrom
turingarena:master

Conversation

@alerighi
Copy link

I've done some fixes to make tmbox work on macOS:

  • add some missing includes
  • change the way memory usage is measured to solve a bug that in some cases leaded to the tmbox process not terminate

Tmbox forks a process that has a loop that calls `ps` to find the
process memory usage. However, at the end of the execution, tmbox
tries to kill this memory watcher process with no success. Tmbox
keeps wait()-ing for the process to terminate, but it never
terminates. Thus tmbox will hang forever till you kill it, leaving
an orphan process on the system.

From POSIX specifications if you send a SIG_KILL to a process it
should *always* terminate. That is not always the case on macOS,
I think the reason is that if the process is in sleep status it
ignores SIG_KILL. This could be a bug of the kernel?

For now I disabled forking a memory watcher process, and instead
I'm calling the function that computes the memory usage from the
main process. This however shouldn't be a problem.

A better solution would be to investigate the system call that
`ps` uses to retrive the data from the kernel and call it directly
from tmbox. Maybe I will implement it in the future, for now this
solution should fix the problem and allow to use tmbox on macOS.
Tmbox forks a process that has a loop that calls `ps` to find the
process memory usage. However, at the end of the execution, tmbox
tries to kill this memory watcher process with no success. Tmbox
keeps wait()-ing for the process to terminate, but it never
terminates. Thus tmbox will hang forever till you kill it, leaving
an orphan process on the system.

From POSIX specifications if you send a SIG_KILL to a process it
should *always* terminate. That is not always the case on macOS,
I think the reason is that if the process is in sleep status it
ignores SIG_KILL. This could be a bug of the kernel?

For now I disabled forking a memory watcher process, and instead
I'm calling the function that computes the memory usage from the
main process. This however shouldn't be a problem.

A better solution would be to investigate the system call that
`ps` uses to retrive the data from the kernel and call it directly
from tmbox. Maybe I will implement it in the future, for now this
solution should fix the problem and allow to use tmbox on macOS.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant