1

I'm running WSL Ubuntu on Windows 10. I have a task to:

  • create an app that builds a small process tree in C++ (done)
  • watch tree through pstree (done, all processes are running, stopped by getchar()
  • And watch what does task//children folder contains in /proc.

The problem is there's nothing like children directory present here. I cd to directory by PID and open task directory. There I see another directory with same PID and nothing else. When I open this directory I see no children file either.

What am I doing wrong?

Edit/update: I found that this is configured by CONFIG_PROC_CHILDREN which seems to be disabled by default. How can I enable this then?

1

My guess is that you are using WSL1. But first ...

when I open this directory I see no "children" dir either

On my system, children is a file, not a directory. Just to make sure you are looking for the right type of item, but I'm guessing you would have spotted it even if it was a file instead of a directory :-).

$ cat /proc/1/task/1/children
9 10

But as I said, I'm guessing this based on your WSL version. Confirm the WSL version (1 or 2) by (from PowerShell or CMD):

wsl -l -v

If, as I suspect, it's WSL1, then it won't have support for CONFIG_PROC_CHILDREN. WSL1 does not use a real Linux kernel, but is instead a "translation" layer which converts Linux kernel syscalls to those of the Windows kernel. Either there's not a direct equivalent to map in Windows, or the WSL team chose not to implement that nuance.

WSL2, on the other hand, does use a real Linux kernel (Github repo). I'm guessing that you are on WSL1 since pretty much all versions of the WSL2 kernel have had CONFIG_PROC_CHILDREN=y in their .config. Here's a link to the oldest WSL2 kernel config settings where you can confirm.

To really do the type of kernel/process inspection you are trying, you'll want to be on WSL2. WSL1 is great for a lot of tasks, but the addition of the "real" kernel in WSL2 is going to smooth out a lot of inconsistencies you might find in the WSL1 "translation" mechanism.

If you have WSL2 installed and configured, you can convert your instance with (again, from PowerShell or CMD):

wsl --export <distroname> backup.tar
wsl --set-version <distroname> 2
1
  • 1
    Man you made my day. I indeed had a WSL1 version, and after converting to second, I got the task to its end. Children is a file indeed, that's a tilted typo, sorry :S Jan 14 at 18:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.