We present a simple and efficient distributed algorithm for detecting generalized-deadlocks in distributed systems. Unlike previous algorithms, which are all based on the idea of distributed snapshot, and require multiple rounds of message transfers along the edges of the global wait-for graph (WFG), the proposed algorithm uses a novel approach that incrementally constructs an 'image' of the WFG at an initiator node. The algorithm has time complexity of d + 1 and message complexity of e + n, where n is the number of nodes, d the diameter, and e the number of edges of the WFG. Compared with the best existing algorithm, our algorithm notably reduces both time and message complexities. Correctness proof and performance analysis for the algorithm are provided. In addition, the new approach simplifies deadlock resolution. An extension to the algorithm is presented to handle generalized-deadlock resolution with only a slight increase to the message complexity.