Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

destroyProcessByID not working with external executables running in child processes #261

Open
waqas-334 opened this issue Dec 26, 2023 · 11 comments · May be fixed by #263
Open

destroyProcessByID not working with external executables running in child processes #261

waqas-334 opened this issue Dec 26, 2023 · 11 comments · May be fixed by #263
Labels
bug Something isn't working

Comments

@waqas-334
Copy link

Hey, I am downloading an RTMP file from a site and using a Timer that reads the size of the file from the disk every second.

Downloading works fine but it continues even after I call destroyProccessById() and it returns true.
In the screenshot, as you can see, the timer prints the file size that is continuously increasing, which means file is being downloaded in the background.

Any remedy for this?
Screenshot 2023-12-26 at 9 19 08 AM

@waqas-334
Copy link
Author

I am using following commands if that helps

-o, -i, --no-part, --download ffmpeg, -v, -d <file_address>

@JunkFood02
Copy link
Collaborator

If you're using an external downloader like ffmpeg or aria2c, it should be launched and running in another process, which is out of our controll. We can only use the Java API to destroy the original process which runs yt-dlp

@waqas-334
Copy link
Author

uh ho, any work around for this?

@farimarwat
Copy link

@JunkFood02 Is it not possible to get PID of ffmpeg and kill that via BuildProcess()/RunTime execution?.
Steps Should be:

  1. List PIDs
  2. Find the lib name in proc/pid/map
  3. If exists() then kill

@JunkFood02
Copy link
Collaborator

JunkFood02 commented Dec 27, 2023

@farimarwat I'm quite busy right now but feel free to try it yourself and submit a PR! If you need additional input then don't hesitate to ask

@waqas-334
Copy link
Author

waqas-334 commented Dec 27, 2023

More findings:
I am convinced that this problem is deriving from yt-dlp, because:

  1. I started the download process using yt-dlp --downloader ffmpeg --no-part "https://cammodels.com/cam/Redhotwifey"
  2. It worked and file begins downloading,
  3. I searched for currently running processes using ps aux | greg yt-dlp -i
  4. Which returned a process details, including the id
  5. I killed the process using kill <process-id>
  6. Process killed but the file continued downloading
  7. I searched for FFmpeg related processes using the above command
  8. That returned 3 ffmpeg-related processes
  9. I killed them one by one, and that made the download process stop.

So the solution would be to figure out the process id that yt-dlp is using to start ffmpeg

@JunkFood02 JunkFood02 added the bug Something isn't working label Dec 27, 2023
@farimarwat
Copy link

farimarwat commented Dec 28, 2023

@farimarwat I'm quite busy right now but feel free to try it yourself and submit a PR! If you need additional input then don't hesitate to ask

I need permissions to create PR. Kindly send me contribution link. Because when ever i try to push a commit, it gives error:

PS C:\Users\BISMILLAH\Downloads\youtubedl-android> git push origin master
remote: Permission to yausername/youtubedl-android.git denied to farimarwat.
fatal: unable to access 'https://github.com/yausername/youtubedl-android.git/': The requested URL returned error: 403

I am working on the issue and almost near to solve this.

@JunkFood02
Copy link
Collaborator

JunkFood02 commented Dec 28, 2023

@farimarwat Please fork this repository and have the work done in your own repo, from which you can submit the pull request to this one

Refer to GitHub docs: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork

farimarwat added a commit to farimarwat/youtubedl-android that referenced this issue Dec 29, 2023
The ProcessBuilder() starts process for Python lib. Python lib further
creates a process for ffmpeg if used for downloading. So the process
returned by .start() method is only capable to kill child
process(python) of the app not sub process(ffmpeg). As this(ffmpeg)
belongs to the app tree, so we are able to kill it even android has
restrctions to kill other's app process.
Tree for process:
App Process(PID)
-Python Process(PID)
--FFMPEG Process(PID)
Now the issue was that if we use "destroyProcessById()" the FFMPEG
process still continue to download the app. So we have to manually kill
this as well.
This patch will solve the bug.
@JunkFood02 JunkFood02 linked a pull request Dec 29, 2023 that will close this issue
@JunkFood02 JunkFood02 changed the title destroyProcessByID not working destroyProcessByID not working with external executables running in child processes Dec 29, 2023
@JunkFood02
Copy link
Collaborator

See also: JunkFood02/Seal#180

@farimarwat
Copy link

@JunkFood02 I have updated my code to target only the selected process. I have tested it and working fine.
For instance if there are 3 processids(running ffmpeg), it will kill that ffmpeg process. So give me feedback and if you agree with the code then kindly merge it. We have to update it in our project.

@JunkFood02
Copy link
Collaborator

@farimarwat Just build the library on your own fork with jitpack https://jitpack.io/#farimarwat/youtubedl-android

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants