info("posixtasks")

The info(“posixtasks”) function list of POSIX shell tasks running in the background.


Description

This function returns a list of POSIX shell tasks running in the background. The list is a carriage return separated list of the task identifiers. See posixtask and posixtask( to learn how background shell tasks are used.

Keep in mind that this list is only accurate at the instant this function is used. You cannot rely on this list even milliseconds later, as the list can change at any time (for example when a background task finishes running). For example, you might be tempted to use this function to check if a background task is running before you kill it.

if arraycontains(info("posixtask"),"My Task",cr())
    stopposixtask "My Task"
endif

However, this won’t work reliably. It’s possible that the task may finish in the time between the if and stopposixtask statements, and then an error will occur. Instead of the code above, you should trap the error like this:

stopposixtask "My Task"
if error
    nop
endif

See Also


History

VersionStatusNotes
10.2NewNew in this version.