Closed
Description
Originally reported by Marc Schlaich (Bitbucket: schlamar, GitHub: schlamar)
It is a common pattern to exit a child process with os._exit
after a fork (ref). However, in this case coverage for the child process fails.
Example:
import os
def child():
a = 1 + 1
assert a == 2
def main():
pid = os.fork()
if pid:
_, systemstatus = os.waitpid(pid, 0)
assert not systemstatus
else:
child()
os._exit(0)
if __name__ == '__main__':
main()
Test run:
$ coverage run -p cov.py
$ coverage combine && coverage report -m
Name Stmts Miss Cover Missing
-------------------------------------
cov 13 4 69% 6-7, 16-17
- Bitbucket: https://bitbucket.org/ned/coveragepy/issue/310
- This issue had attachments: coverage_issue310.tar.gz. See the original issue for details.