OpenKore / openkore

A free/open source client and automation tool for Ragnarok Online
http://openkore.com
Other
1.28k stars 1.04k forks source link

OpenKore console hangs after async task #1158

Open deezar opened 7 years ago

deezar commented 7 years ago

I'm trying to extend OpenKore's functionality by writing a plug-in which makes use of asynchronous task whenever I use a skill.

Perl fork module is having a problem with OpenKore console. Here's the simple code snippet from my plug-in

sub on_skill_use {
    my (undef, $args) = @_;

    print "Before doing async task.\n";

    unless (fork) {
        print "Doing something for 5 seconds without blocking OpenKore.\n";
        sleep 5;
        print "Task done.\n";
        exit;
    }

    print "Continue with something else for now...\n";
}

The async task done just fine. OpenKore console printed something like this:

Before doing async task.
Continue with something else for now...
Doing something for 5 seconds without blocking OpenKore.
Task done.

After the last line which indicates async task has done, OpenKore console hangs. It won't accept any direct input into the console and won't print anything out.

However if I try XKore and send command from chatbox like ;pl the result will be displayed in-game chatbox but not in OpenKore console. This means OpenKore is still working past that async task but the console display is hanged.

Or there's a better way of doing background, non-blocking or async task?

Appreciate any help.

Nipodemos commented 5 years ago

do you still have any interest in make this plugin?