2

I need to test from shell (in a predictable way) if I'm currently running under WSL. How should I go about doing this?

This is what uname -v returns on Windows Anniversary update: #1 PREEMPT Thu Aug 1 17:06:05 CST 2013

I wonder what PREEMPT is. Should I use this?

EDIT: No, PREEMPT seems to be unrelated to WSL

EDIT 2: A bad hack would be: $(ps auxww | grep root | grep -v grep | wc -l) -lt $ASMALLNUMBER

Guy Coder
  • 24,501
  • 8
  • 71
  • 136
0fnt
  • 8,211
  • 9
  • 45
  • 62
  • `PREEMPT` is a flag coming from the kernel, meaning that it supports preemption. You can't rely on this. – Daniel Kamil Kozar Aug 18 '16 at 17:07
  • 1
    I think this is what you're looking for. https://stackoverflow.com/questions/38859145/detect-ubuntu-on-windows-vs-native-ubuntu-from-bash-script – Darren Aug 18 '16 at 18:33
  • @Darren Thank you. I've voted to close this. – 0fnt Aug 19 '16 at 10:05
  • I's suggest the *recommended* way is: don't. It shouldn't need any special handling; why do you want to know? Is there another way to do it? – Adam D. Ruppe Aug 27 '16 at 01:09
  • @AdamD.Ruppe I have a single version of rc/config files for all my unix instances- I need to start zsh as soon as bash starts if currently running under wsl – 0fnt Aug 31 '16 at 16:03

0 Answers0