Here is your answer
The grammatical significance of some words depends on its usage in a sentence.
Same is in the case of "who".
It is both relative and interrogative.
Usage in sentence as Relative
The man who is standing near the gate is my friend.
Usage in sentence as Interrogative
Who are you?
We can easily identity if "who" is used as an interrogative by checking whether a sentence ends with a question mark (?).
For its use as relative the meaning of sentence can tell us whether two parts are related to each other.
HOPE IT IS USEFUL